程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> C++讀取“aux”,“com*”文件

C++讀取“aux”,“com*”文件

編輯:C++入門知識

From Neeaos Blog

Windows 下不能夠以下面這些字樣來命名文件/文件夾,包括:“aux”,“c++om1”“com2”“prn”“con”和“nul”等,但是通過cmd下是可以創建此類文件夾的,使用copy命令即可實現:

\

這種文件通過gui是無法訪問的,如下圖:

\

但是通過IIS還是可以解析這個文件的:

\

那麼是否可以用程序讀取麼,於是乎就測試了一下,用VS2003創建了一個項目,代碼如下:

#include "stdafx.h"
#include <fstream>
#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 ifstream fin("F:\asp\com1.asp");
 string s;
    while(getline(fin,s) )
    {  
        cout << "Read from file: " << s << endl;
    }
 system("pause");
 return 0;
}
讀取com1.asp並輸出,如果可以讀取的話,可以輸出com1.asp內容,看圖:

\

沒有任何輸出,看起來是不能直接讀取了,Google一把:

html">http://blog.sina.com.cn/s/blog_4a72966b01000ana.html

找到這篇文章,說cmd下刪除aux文件的,那我們通過其中說的方法看能不能讀取,修改下代碼:

#include "stdafx.h"
#include <fstream>
#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 ifstream fin("\\.\F:\asp\com1.asp");
 string s;
    while(getline(fin,s) )
    {  
        cout << "Read from file: " << s << endl;
    }
 system("pause");
 return 0;
}
運行下看看:

\

可以正常讀取了,^_^。

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved