I had developed an application in VS2008 with .NET 2.0 . The application was deployed using the VS2008 deployment project  with .NET Framework as pre-req. AutoCAD 2009 was already installed on all the client machines so the pre-req conditions were satisfied so .NET Framework was not skipped during the installation of the application.

Later on,  I made a clean installation of WIN XP SP3 on my development machine. I skipped VS 2008 because I could not find its proper usage. VS2005 was sufficient for me.

Today, I got the a request for some updates in the application. For this purpose, I converted it to VS2005. On building the application is got the error about OpenFileDialog.SafeFileName. It was really a strange thing as the application was working smoothly on all the client machines.

SafeFileName returns only the File Name from the whole path. Although, I got the problem solved by doing some string operations:
String safeName = opdg.FileName.Substring(opdg.FileName.LastIndexOf("\") + 1);
// 1 has been added to skip the

I Googled about it and it was disclosed that this property is available in .NET Framework 2.0 SP1 which is installed along with VS2008.

2 thoughts on “OpenFileDialog.SafeFileName”

  1. If there is any error while processing SafeFileName then it is bcoz of .NetFrame Work..
    if it s not installed properly,then SafeFileName wont come under System.Windows.Forms.OpenFileDialog

  2. NO, there is still no other issue so we cant relate it to the installation.
    also, it seem that u hav not checked the link (caption Googled) in the end of the post:


Leave a Comment