Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenFileDialog - InitialDirectory open a remote directory

Tags:

c#

I have been trying to use the InitialDirectory on remote server without success. What I am trying to do is that: (comboBox1 has name of servers)

OpenFileDialog ofLogFile = new OpenFileDialog();
ofLogFile.Title = "Log for server: " + comboBox1.text;
OpenFileDialog.InitialDirectory = "\\\\" + comboBox1.text + "\\c$";
ofLogFile.RestoreDirectory = true;

and then there is an if check..

But it doesnt work. All i get is the local machine directoies. The thing is, when i put into InitialDirectory-

    OpenFileDialog.InitialDirectory = @"\\server_name\c$";

It works just fine. Another thing that i tried to put is:

OpenFileDialog.InitialDirectory = "\\\\" + ((System.Data.DataRowView)
(this.comboBox1.SelectedItem)).ToString + "\\c$";

It also doesnt work.

I am starting the program with the appropriate permissions so it shouldn't be an issue. any suggestions?

like image 373
user1370184 Avatar asked May 25 '26 16:05

user1370184


1 Answers

Shouldn't it be:

ofLogFile.InitialDirectory = "\\\\" + comboBox1.text + "\\c$";

?

like image 101
banging Avatar answered May 28 '26 05:05

banging



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!