>
KenL.Net  A Developer's Expedition






Skip Navigation Links
Home
Skip Navigation Links
Architecture
Skip Navigation Links
Windows
Skip Navigation Links
Web
Skip Navigation Links
Sharepoint
Skip Navigation Links
Data Development

Architecture

Application location and the Microsoft Logo Program

One of the elements of Microsoft's logo requirements is your application runs in the program directory. So where is the program directory? If you think it is C:\Program files\ well you are not totally correct. It is true your computer and most computers that is the correct location. But it is not the correct location. For starters Windows can be installed on any drive. For example you can install and run Windows on your D: drive. Another more common reason for ensuring your program can run on a different drive than the C drive is CITRIX. If you have not heard of CITRIX you should go to Citrix.com. Basically Citrix is the ultimate in terminal services. It allows system administrators the ability to install software on the server and the users to terminal in to operate that program. On both the functional scale and the cool scale it is a 10! When CITRIX is installed on the server it changes the main drive path from C: to something else. This is because of the terminal emulation of this drive to the client computer (programs that are installed on CITRIX run seamlessly on the client computer).
 
So what does this matter you ask. If your application reads and writes to a files, for example a XML file or any file access, the chances are you pointed your document directly to the C: drive. What will happen to your app when it does not find a C: drive? Is your norm to add exception handling for your file access? Luckily the .Net frame work offers Application.ExecutablePath which returns the exact location of the exe file. To return the actual drive that the application is working on use Application.ExecutablePath.ToString().Substring(0, 3) to pull the first 3 characters in the execution path. So now instead of having this line of code that will throw and exception when the drive is not the C: drive XmlTextWriter textWriter = new XmlTextWriter(@"C:\Program Files\MyProgram\MyXML.xml", Encoding.UTF8); you should be using XmlTextWriter textWriter = new XmlTextWriter(Application.ExecutablePath.ToString().Substring(0, 3) + @"\Program Files\MyProgram\MyXML.xml", Encoding.UTF8); Thus your application passes one of the Microsoft logo requirements. And for the record if you are using the line of code above? You are using ugly code. Put the location in a string!




More Recent Solution Architecture Articles:



KenL.Net - Home Page of Ken Lovely, MCSE, MCDBA free source code, .NET Development, .NET technology, .NET platform, .NET, Windows Longhorn, longhorn programming, aero, avalon, Indigo, Longhorn, WinFS, WinFX, XAML,Longhorn SDK, C#, C#.NET, C# .NET, CSharp, Windows Longhorn, Whidbey, Visual Studio .NET, XAML, Avalon, Aero, WinFS, WinFX, Avalon, dot net, dotnet, .net, csharp, c sharp, c, sharp, c-sharp, C#, dotnet, VC#, Visual C#, .NET, ASP, ASP+, CSharp, C-Sharp, VB.NET, XML, SOAP, dot net jobs, contracts, books, downloads, software, Java, J#, Visual J#, JSharp, j-sharp, cobol, cobol.net, cobol dot net, speech.net, speech, mobile programming, threading, security, .net security, xml.net, printing, training, dot net training, Tutorials, Articles, Programming, web forms, windows forms, ASP.NET, Web services, XML Web services, Visual studio .net, VC++.NET, managed extensions in C++, MFC, ATL, COM, COM+, DCOM, Pocket PC, Embedded& developement, JScript .NET, VBScript .NET, Mono Project, Eiffel .NET, Windows CE .NET, Magazines, ADO.NET, Cryptography, Active Directory, DirectX, Exception Handling, GDI+, GDI, Strings, Arrays, C# Language, Applied .NET, ken lovely, mcse, mcad, mcsd, mcdba