2010-12-09 67 views
0

雖然文件存在於物理位置FileInfo.Length返回錯誤FileNotFoundExceptions。我想告訴你,該文件是一個虛擬文件。我到目前爲止所做的工作引發FileNotFoundException但文件存在

string [email protected]"N:\Orders\SubFolders\group.indd"; 
FileInfo fileInfo=new FileInfo(filePath); 
string modifiedDate = fileInfo.LastWriteTime.ToString("MM/dd/yyyy HH:mm:ss");          
string fileSizeInKB = string.Format("{0:0,0 Byte}", fileInfo.Length); 
+0

`fileInfo.LastWriteTime`返回正確的值沒有錯誤? – 2010-12-09 07:03:14

+0

它返回一個值,但不是正確的一個 – rashim 2010-12-09 07:04:34

回答

0

該文件被標記爲目錄,處於低級別。

這裏是FileInfo類的get_Length方法中的代碼:

if ((this._data.fileAttributes & 0x10) != 0) 
{ 
    __Error.WinIOError(2, base.DisplayPath); 
} 

的代碼2的意思是「FileNotFound」例外,並且十六進制0x10的代碼是十進制16。

的FileAttributes枚舉包含此:

// 
// Summary: 
//  The file is a directory. 
Directory = 16, 

那麼,什麼是 「group.indd」?從來沒有聽說過這樣的擴展,所以你能詳細說明究竟是什麼?

相關問題