0

I need to find a files's meta data using c#.The file i use is saved in third party site. I can able to download the file from that server but i can't able to get the original meta data of the file that i downloaded. How to achieve this using c#.Below is my code.

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;
                }
            }

I can able to get file size,creation time,last accessed time and last write time only after saving the file in local. But i need the file meta data infos when file is located in server using c#.

Thanks

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44
Arun
  • 1,644
  • 9
  • 25
  • 41
  • Here is the few links of Related Question and Detail about Reading meta data using reflection. http://stackoverflow.com/questions/220097/read-write-extended-file-properties-c/2096315#2096315 http://computer.financialexpress.com/20030113/techspace2.shtml – SaravanaKumar May 27 '13 at 10:57

1 Answers1

0

Since those are properties stored in the file system and changed once you save them locally, you won't be able to access those via HTTP.

Do you have any influence on the third party? Maybe have them send those properties along in the headers?

Alexander
  • 2,457
  • 1
  • 14
  • 17