开发者

Accessing http://< someserver.com/logs:<someportnumber> > in client side using c# code

I have a scenario in my mind .. I need validations/suggestions from Stack over flow !! :) There is a (remote)开发者_运维知识库apache server hosting this URL "http://someserver.com/logs/log.txt:4041" .When i hit this URL in IE it opens a page containing log.txt in a file-folder-directory structure (after authentication). Is there any way to get the attributes of the log.txt (attributes what i mean is file creation date,file modification date,file size etc..).

What I am planning to do is to write a code in C#.net(in the client) using system.IO namespace and using the fileinfo class and use FileInfo fi = new FileInfo(pathname); fi.CreationTime.toString() to retrieve the file creation time.

This is successful for files that exists in local directories in my hard drive!! . Is it possible to use the same code for retrieving the information about the file that exists in the server that is accessed using the URL "http://someserver.com/logs/log.txt:4041" ?? if yes should i give the URL in my pathename ? Take it for granted that i have access to the server by authentication..


You can try to inspect the data in WebResponse.Headers. The web server will send some date/time information of the file with the response. This may however not be what you expect depending on the web server you're calling and whether the page you are loading is a script or a file on disk. Settings of the web server will also influence the details returned.


You will not be able to use FileInfo method for items retrieved from http. However if the directory that the file that you are getting served to you is accessible from a share of from samba you could use this method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜