要求:几个客户机向服务器导入文件,(同文件名接着添加)。
我写了个程序:大概是
CStdioFile file;
if(file.Open(("c:\\1\\"+strFileName),CFile::modeRead))
{

while(file.ReadString(strTEMP))
{
     str = str+strTEMP+"\n";
     strTEMP="";
 }
}
file.Close();ofstream MacFile;
MacFile.open("\\\\172.26.8.2\\sf\\2\\"+strFileName,ios::app);//服务器文件设成共享,可读写
if(!MacFile.is_open())
{
AfxMessageBox("Save file failed");
return 0;
}
else
{
MacFile << str ;

}
MacFile.close();///
大概用的这种方法,其他声明定义我就不贴了。现在的问题是,客户机同时导入的时候,服务器上的文件会很乱(一会儿是a的文件,一会儿是b的文件,),还会丢失文件,这是为什么?怎么解决呢 ?期待好方法!谢谢。