0
我需要使用c#來查找文件的元數據。我使用的文件保存在第三方站點中。 我可以從該服務器下載文件,但無法獲取我下載的文件的原始元數據。 如何使用c#.Below實現這一點是我的代碼。使用c獲取文件的元數據#
string FilePath = AppDomain.CurrentDomain.BaseDirectory + @"Downloads\";
string Url = txtUrl.Text.Trim();
Uri _Url = new Uri(Url);
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(_Url);
request.Timeout = Timeout.Infinite;
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
response.Close();
if (response.ContentType != "text/html; charset=UTF-8")
{
string FileSize = response.Headers.Get("Content-Length");
int lastindex = Url.LastIndexOf("/");
string TempUrlName = Url.Substring(lastindex + 1, Url.Length - (lastindex + 1));
WebClient oWebClient = new WebClient();
oWebClient.DownloadFile(txtUrl.Text.Trim(), FilePath + @"\" + TempUrlName);
if (File.Exists(FilePath + @"\" + TempUrlName))
{
FileInfo oInfo = new FileInfo(FilePath + @"\" + TempUrlName);
DateTime time = oInfo.CreationTime;
time = oInfo.LastAccessTime;
time = oInfo.LastWriteTime;
}
}
我也只能夠保存文件在本地後得到的文件大小,創建時間,上次訪問時間和上次寫入時間。但是當文件位於使用c#的服務器中時,我需要文件元數據信息。
感謝
以下是關於使用反射讀取元數據的相關問題和詳細信息的鏈接。 http://stackoverflow.com/questions/220097/read-write-extended-file-properties-c/2096315#2096315 http://computer.financialexpress.com/20030113/techspace2.shtml – SaravanaKumar