saveFileDialog SafeFileName Not Available ! RRS feed

  • Question

  • I am using VS2008 w/SP1, and .NET 3.5 sp1 installed,

    While SafeFileName is documented as being available in .NET 3.0, I am having this error when I attempt to compile a C# application:

     error CS1061: 'System.Windows.Forms.SaveFileDialog' does not contain a definition for 'SafeFileName' and no extension method 'SafeFileName' accepting a first argument of type 'System.Windows.Forms.SaveFileDialog' could be found (are you missing a using directive or an assembly reference?)

    I have of course tried adding a few references but nothing has appeared to solve this problem that appears when using the saveFileDialog with SafeFileName. (openFileDialog works fine.)

    Should I uninstall 3.5 SP1 and re-install it ?

    My next guess at this point was that I need .NET 2.0 and related SP's installed, as they're not. Even though the 3.5 SP1 should have updated any relevant files.
    Friday, December 4, 2009 9:44 AM

All replies

  • Your project isn't targeting .NET 2.0 is it? It's an option in the project properties.
    Phil Wilson
    Friday, December 4, 2009 5:57 PM
  • Originally it was. Once I noticed I needed .NET 3.0 for SafeFileName, I changed that to 3.5.

    However most of the references are still only picking up the .NET 2.0 libraries. So I removed ALL the references and re-added them. That didn't change anything.

    I'm using Vista x64 which I think compounds the problem because I am unable to install either 2.0 SP's for some reason. But given I am up-to-date with 3.5 SP1, I didn't think I needed to do so. I have the same problem with this project on a second Vista x64 system. So it's not directly related to one computer.
    Friday, December 4, 2009 6:49 PM
  • In addition I note that this succeeds,

    C:\>Winmgmt /verifyrepository
    WMI repository is consistent

    And the Net Setup Verifier utility correctly verifies both 2.0SP2 and 3.5 SP1. (Actually all the .NET frameworks)

    So I expect I have run into a limitation of the API, probably on x64.
    Friday, December 4, 2009 7:47 PM
  • Hi rhenley

    Can you clarify the steps to reproduce the problem?
    What does the source code looks like?


    Figo Fei

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, December 7, 2009 6:56 AM