Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I capture the UNC for my Current Directory?

Status
Not open for further replies.

jgpasko

Programmer
Dec 6, 2001
48
US
I need to capture the UNC for the Server I am running my app on to determine if it is a QA or PROD Environment. When I use the following code, I only get the drive path, not the actual server path.

// Get the current directory.
string path = Directory.GetCurrentDirectory();

I also have the following .NET Namespaces

using System;
using System.IO;
using System.Text;

Instead of returing:

\\prodserver\Shared\error_logs
I get L:\Shared\error_logs
Any help will be appreciated.

Thanks,

John

John Pasko
john@rts-sd.com
"No matter where you go, there you are."
 
Try thread796-827579 this thread. It is in VB .NET so might have to convert that to C#.

-Kris
 
Kris,

Thanks for the reply. I was just entering that I found the solution.

I am using the Environment.MachineName property and this seems to have worked.

Again, thanks for the response.

John

John Pasko
john@rts-sd.com
"No matter where you go, there you are."
 
John,

Environment.MachineName will give you the local computer name not the server Name (unless you are using ASP .NET and want only the web server name).

-Kris
 
Kris,

The Assembly is going to be running on 2 servers (QA and PROD) so I will get the server names (Local Machine) as the UNC.

John

John Pasko
john@rts-sd.com
"No matter where you go, there you are."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top