You must Sign In to post a response.
  • Category: Windows

    How I can get name and path of the file which opened my application

    Hi All,

    I am working on a windows application. I build a setup application and installed. If I am opening an xml file from my desktop and "open with my application", i want to get the file and path of that xml file.

    Please help me. let me know if you have any queries.

    Thank you all
    suneer.
  • #617788
    Please check the following code:


    private void button1_Click(object sender, EventArgs e)
    {
    OpenFileDialog openFileDialog1 = new OpenFileDialog();
    openFileDialog1.ShowDialog();;
    foreach (string s in openFileDialog1.FileNames)
    {
    MessageBox.Show(s);
    }
    }


    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #617812
    Please build the application with app.config file after you installed the software please modified app.config file like this.


    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    </configSections>
    <connectionStrings>

    </connectionStrings>
    <appSettings>

    <add key="ConnXml" value="C:\Product.xml" /> [Here you can set the path]
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    </appSettings>

    </configuration>

  • #617912
    Hi Paritosh,

    Thank you for your reply. If I open using OpenFileDialog, I can get the file name and path.

    But if you are simply opening any file from your system. ie, right click on the file and select "open with" and select your exe,then your application will be open, but how i can get that file name and path which i selected and opened?

    Please help me.

    Thanks a lot
    suneer


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.