I am not sure whether is this call dynamic path. but what i want to do is to make a directory that is at the root of the C# file.

because when i search for directory if i put

if (File.Exists(@"D:\hello.txt"))
                {
                    Download(@"/root", 0, 0, 0, -1, 0, true);
                }
else
               {

               }

what if the computer does not have D driver. so i want to make a dynamic path which is at the root of the C#.

thank you.

Please use code tags when posting code on daniweb:

Which is why you should use the application data path for storing files so you dont run in to that issue:

string newPath = Path.Combine(Application.UserAppDataPath, "Download.txt");

You can take a look at the drive letter of the user app data path or the processes file path:

private void button2_Click(object sender, EventArgs e)
    {
      string s1 = System.IO.Path.GetPathRoot(Application.UserAppDataPath);
      string s2 = System.IO.Path.GetPathRoot(Application.ExecutablePath);
      MessageBox.Show(s1 + "." + s2);
    }

If you run an assembly from a UNC that has not been installed on the local machine then both of those calls may fail to produce a drive letter. Why not prompt the user with a save dialog?

Hi

Try this code

pathdb=System.IO.Path.GetDirectoryName(System.Refl ection.Assembly.GetEntryAssembly().Location);

pathdb=pathdb+@"\database";

Thanks,
Paul daniel

if (File.Exists(@"D:\hello.txt"))
                {
                    Download(@"D;/hello.txt", 0, 0, 0, -1, 0, true); // a C++ dllimport download command.
                }
else
               {
                    // some coding to open a dialog box if the file in "D:\hello.txt" did not exist. So after i selected the file from the dialog box, it will run "Download(@"the selected directory by dialog box", 0, 0, 0, -1, 0, true);"  (do it manually)
               }

so what im asking is i want to replace the "D:\hello.txt" directory to another directory that is inside your application root.

hope this is more clear.
i will try the solution given later on as i have to sleep now.

Thank you both for replying and helping me.

once again, thank you.

string[] files = System.IO.Directory.GetFiles(settings, "*.txt"); I was try for this one

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.