Skip to main content

SafeFileName Property and .Net 2.0 SP1

I built a small utility using C# Dot Net version 2.0 in which I took help of Open File Dialog box windows control to know user selected file path and name. I used “SafeFileName”(Gets a string that only contains the filename for the selected file.) property of OpenFileDialog box to display selected filename on the windows form. I did a fine testing on my development machine and deployed it on production computer. The production computer was up by freshly installed Windows Vista operating system (without SP1 update). since Vista ships with DotNet runtime, my job was as easy as copying my dot net executable assembly and double clicking it. When the OpenFileDialog box tried supplying user selected file name through “SafeFileName” property, it crashed! Damn...!!

The error message was clearly telling me that “method not found: OpenFileDailog.get_SafeFileName()”!! I was darn surprised. Though I did a quick fix for this problem by making use of FileName property (Gets or sets a string containing the full path of the file selected in a file dialog.), with little string manipulation to extract filename from complete file path and got the required result, the unsupported property error on Vista machine continued interrupting my thoughts. I did not see any documentation or remarks giving specific attention to this issue anywhere in Microsoft's official web space. When I installed Dot Net 2.0 SP1 (on production computer) and run my utility (without FileName property fix). This time there is no “method not found” error! The .Net 2.0 SP1 has fix for it though there is no specific note on this in Microsoft’s support knowledge base article http://support.microsoft.com/kb/945757
This experience taught me that, Before I go ahead copy my any 2.0 framework based dot net utility and run on any computer, make sure machine has got .Net 2.0 SP1 update or not.

Comments

Popular posts from this blog

How a university is saving 2.5 tons of paper every year?

Considering the current environmental imbalances, many non-profit organizations (like The Nature Conservity , SayTree …and many others) around the world working desperately to save plant  and trees. It is our responsibility too. We felt starting with universities is the better place to spread the awareness. With this, we also made universities administrative work more manageable and effective. The story I am going to share tells you how a university quietly worked and stands as a role model by saving tons of paper and millions of rupees of its own and its students. In the year 2012, VT University (Visvesvaraya Technological University also popularly known as “ VTU ”) Belgavi (India), has moved its thesis evaluations to online to effectively reduce its use of paper and streamline the process online. University’s this decision made it save several Lakhs of rupees (~ tens of thousands of dollars) every year in paper cost while giving faculty and administrators more direct a...

Why Akbar was Great?

I have fanatical interest to be acquainted with what made Indian emperors take influential decisions during their reign. Few great kings’ valuable decisions created a remarkable history. When Akbar accepts the marriage proposal of Hindu King (Bharmal of Amer), he wishes to make an attempt to set an example for two culture and religions and convey the message of peace. Later, destiny takes him to the critical path of life having most depraved political and family oriented problems. Being a true great emperor, Akbar learns and conclude challenges by demonstrating his exceptional leadership qualities. With his verdicts, Akbar stands as an incomparable king of all time. “Jodha Akbar” – brings 16th-century incidents to life and shows beginning part of Akbar’s married life which was, in fact, a deal for political gain. This decision slowly unleashes Akbar’s loving life, internal dreadful politics, painfully desirous people around him and betraying family members. Jalaluddin Mohamma...

Windows forgets visual effects settings on log-out or reboot for non-administrator account

Steps given here worked for me with Windows 7 SP1. Hope you may find it useful. Start -> Run-> cmd (press enter) -> type SystemPropertiesPerformance.exe This gets you the "System Properties" window, go to   Advanced tab -> Performance Settings -> Visual Effects tab and choose "Adjust for best performance" and click OK. Note: While doing all these UAC doesn't show-up as all changes you are doing will be saved in your logged-in profile account. Reference material used:  http://msdn.microsoft.com/en-us/library/ee330866.aspx Feel free to comment your findings.