问题描述
我有一个应用程序,它从我的系统中映射的网络驱动器中读取文件。
此文件在一台机器中创建(比如Machine-A )到其本地驱动器并尝试使用fopen()从另一台机器(比如Machine-B)打开。但即使Machine-A创建的文件,Machine-B也无法使用fopen()访问该文件。
当我在循环中尝试fopen()时,然后发现有些时间仅在3-4秒后fopen成功。但是我可以在fopen获得成功之前在Windows资源管理器中看到创建的文件。
注意:此问题仅在Windows7计算机中发生。这两台机器都是windows7。
请提出解决方案,如果有人已经遇到过这个问题。
请参阅我用于阅读文件的代码。
for(int nIndx = 0; nIndx< 100000; nIndx ++)
{
fp = fopen(Z:\\TEST \\SAMPLE.000,r); //从网络驱动器打开。
if(NULL!= fp)
{
OutputDebugString(_T(File Found !!!));
fclose(fp);
AfxMessageBox(_T(File Found !!!));
休息;
}
else
{
OutputDebugString(_T(File not found ...));
}
}
I have an application which reads the file from a network drive which is mapped in my system.
This file is created in one machine (say Machine-A) to the its local drive and trying to open from another machine(say Machine-B) using fopen(). But even though the file created by Machine-A, Machine-B cannot access the file using fopen().
When I tried the fopen() inside a loop, then it is found that some timed only after 3-4 seconds fopen is success. But I can see the created file in windows explorer before the fopen gets success.
Note: This issue is happening only in Windows7 machine. Here both machines are windows7.
Please suggest solution, if anyone already faced this problem.
Please see the code which I used for reading the file.
for( int nIndx = 0; nIndx < 100000; nIndx ++ ) { fp = fopen( "Z:\\TEST\\SAMPLE.000", "r" ); // open from Network drive. if( NULL != fp ) { OutputDebugString( _T( "File Found !!!" )); fclose( fp ); AfxMessageBox( _T( "File Found !!!" )); break; } else { OutputDebugString( _T( "File not found ..." )); } }
这篇关于即使文件存在于网络驱动器中,也不会成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!