开发者

Get Server folder from a server IP

How to get the folder of a server 开发者_开发知识库for ex: 170.1.1.1 there is a folder Info in C:\, using c# is there a way to get C:\info drive for a server?

Am not able to get it right?


If there is no share on this folder or on c:\ but the user that runs the app has admin-rights, try to open \\IP-Address\c$\info\filename.txt

string path = @"\\IP-Address\c$\info\filename.txt"
if (File.Exists(path)){
    using (StreamReader sr = File.OpenText(path)){
        string s = "";
        while ((s = sr.ReadLine()) != null)
        {
            Console.WriteLine(s);
        }
    }

}


Only if that server is sharing that folder somehow. Are you talking about browsing it as a network share? Getting a directory listing from a web server?


Use the tool folderBrowseDialog and into properties change SelectedPath into your desired IP-Address.

If you are using button to activate codes, insert this.

    private void button1_Click_1(object sender, EventArgs e)
    {
        if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
        {
            txtfilename.Text = folderBrowserDialog1.SelectedPath;
        }  
    }

Hope it will helps...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜