📄 subject_42565.htm
字号:
<p>
序号:42565 发表者:lylouie 发表日期:2003-06-04 11:16:35
<br>主题:fp=fopen(".//config//project.wkf","r"); ".//"中的"."是什么意思?
<br>内容:vc 6.0<BR>运行好好的. <BR>CHistoryDlg dlg;<BR>//////////////////////////////////////////////////////////////<BR>//intiate CHistoryDlg. Set stationID and which channel data will be view.<BR> FILE* fp=NULL;<BR> fp=fopen(".//config//project.wkf","r");<BR> if(fp==NULL)<BR> {<BR> AfxMessageBox("无配置文件");<BR> return;<BR> }<BR> fseek(fp,16L,0);<BR> fscanf(fp,"%d",&dlg.m_stationID);<BR> fseek(fp,19L,0);<BR> fscanf(fp,"%d%;%d%;%d%;%d%",&dlg.m_ch1,&dlg.m_ch2<BR> ,&dlg.m_ch3,&dlg.m_ch4);<BR> fclose(fp);<BR>//////////////////////////////////////////////////////////////////<BR> if(dlg.DoModal()==IDCANCEL)<BR> return;<BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:管理员 回复日期:2003-06-04 11:18:23
<br>内容:应该是".\\a\b.txt"<BR>\在字符串中是转义符号,例如\n \t<BR>所以\要用\\来表示
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:管理员 回复日期:2003-06-04 11:19:21
<br>内容:还有一点在WIN系统下目录分隔用\<BR><BR>在unix下用/<BR>所以如果是UNIX下用"./a/b.txt"就可以了
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:lylouie 回复日期:2003-06-04 11:34:28
<br>内容:我用的好好的<BR>".//",""..//","//"有何区别?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ohye212 回复日期:2003-06-04 11:38:12
<br>内容:表示当前目录!!!!!!!!!!!!!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:moli 回复日期:2003-06-04 11:38:30
<br>内容:我好像用/还是用\都没什么区别亚,都可以吧?有哪位知道请解答一下吧?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:lylouie 回复日期:2003-06-04 11:52:34
<br>内容:我试了<BR>两种用法都可以,不知为何?<BR>但上面代码我第一次运行可以<BR>以后提示"无配置文件"<BR>整个程序重新运行后又是如此?<BR>为何?<BR> CStationNetDlg dlg;<BR>//////////////////////////////////////////////////////////////<BR>//intiate CStationNetDlg. Set stationID and which channel data will be view.<BR> FILE* fp=NULL;<BR> fp=fopen(".\\config\\project.wkf","r");<BR> if(fp==NULL)<BR> {<BR> AfxMessageBox("无配置文件");<BR> return;<BR> }<BR><BR> fseek(fp,19L,0);<BR> fscanf(fp,"%d%;%d%;%d%;%d%",&dlg.m_ch1,&dlg.m_ch2<BR> ,&dlg.m_ch3,&dlg.m_ch4);<BR> fclose(fp);<BR>//////////////////////////////////////////////////////////////////<BR><BR>//////////////////////////////////////////////////////////////<BR> <BR>/////////////////////////////////////////////////////////////////////<BR>//At first,set directory.<BR> char OldPath[50]="";<BR> ::GetCurrentDirectory(50,OldPath);<BR> char Pathname[]=_T(".\\m200203");<BR> CTime t=dlg.m_date;<BR> sprintf(Pathname,".\\m%04d%02d",t.GetYear(),t.GetMonth());<BR> if(!::SetCurrentDirectory(Pathname))<BR> {<BR> ::CreateDirectory(Pathname,NULL);<BR> ::SetCurrentDirectory(Pathname);<BR> }<BR>//////////////////////////////////////////////////////////////////<BR> FILE* fp1=NULL;<BR> char m_twid[5][2]; <BR> fp1=fopen("..//config//stationnet.wkf","r");<BR> if(fp1==0)<BR> fp1=fopen("config//stationnet.wkf","r");<BR> else<BR> {<BR> while(!feof(fp1))<BR> {<BR> int i=0;<BR> fscanf(fp1,"%s",m_twid[i]);<BR> AfxMessageBox(m_twid[i]);<BR> i++;<BR> <BR> }<BR> fclose(fp1);<BR> }<BR>// m_twid[0] = {'1'};<BR>// AfxMessageBox(m_twid);<BR>/////////////////////////////////////////////////////////////////////<BR>//pass all filenames to the open-document function. <BR> char filename[200]={""};//initiate into blank;<BR> CString temp;<BR> CFileFind finder;<BR> char* pfn=filename;<BR> UINT m_ch[4]={dlg.m_ch1,dlg.m_ch2,dlg.m_ch3,dlg.m_ch4};<BR> int twid[3];<BR> for (int i=0;i<4;i++)<BR> twid[i] = i;<BR> for(int j=0;j<4;j++)<BR> {<BR> for(int i=0;i<4;i++)<BR> {<BR>// temp.Format("m%02s%02d%X%02d.%02d",1,i+1,t.GetMonth(),t.GetDay(),t.GetYear()%100);<BR> if(m_ch[i]!=0)//Whether this channel is selected?<BR> {<BR>// temp.Format("m%02d%02d%X%02d.%02d",i,i+1,t.GetMonth(),t.GetDay(),t.GetYear()%100);<BR> // temp.Format("m%02s%02d%X%02d.%02d",,i+1,t.GetMonth(),t.GetDay(),t.GetYear()%100);<BR> temp.Format("m%02d%02d%X%02d.%02d",twid[j],i+1,t.GetMonth(),t.GetDay(),t.GetYear()%100);<BR> AfxMessageBox(temp);<BR> if(finder.FindFile((LPCTSTR)temp))<BR> {<BR> finder.FindNextFile();<BR> temp=finder.GetFileName();<BR> memcpy(pfn,(LPCTSTR)temp,temp.GetLength());//copy whole path.<BR> pfn+=11;<BR> }<BR> }<BR><BR> }<BR> }<BR> *pfn=0;<BR> AfxMessageBox(filename);<BR>/////////////////////////////////////////////////////////////////<BR>//Now begin to pass parameters;<BR> if(*filename!=0)<BR> ((CMainApp*)AfxGetApp())->pDocTemplate->OpenDocumentFile(filename);<BR>/////////////////////////////////////////////////////////////////<BR> ::SetCurrentDirectory(OldPath);<BR>/////////////////////////////////////////////////////////////////<BR> if(dlg.DoModal()==IDCANCEL)<BR> return;<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:moli 回复日期:2003-06-04 14:29:25
<br>内容:可能第一次运行的默认的当前路径和后来运行的当前路径是不一样的,所以找不到文件而出错,你为什么不把路径写清楚呢?或者用GetCurrentDirectory来得到当前路径?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -