I assume you are using a OpenFileDialog control in a Windows Forms application and perhaps you are trying to retrieve the File's full path in the Form_Load() event. That is:
private void Form1_Load(object sender, EventArgs e)
{
string filePath = Path.GetFullPath(openFileDialog1.FileName);
}
If you try to retrieve the full path in the Form_Load event, system will provide you the current directory Path, that is, the dll or exe from where the application is running. May be that's what is happening in your case.
What you need to do is, you should try to retrieve the File's full path after selecting the file using the OpenFileDialog control. Here are the steps:
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
string filePath = Path.GetFullPath(openFileDialog1.FileName);
}
Hopefully, this will resolve your issue.