0

I have written the following code for creating a file and it works fine...

string dirAddress = "C:\\FTPTrace\\" + ipHeader.DestinationAddress.ToString() + ".txt";

System.IO.StreamWriter logfile = new StreamWriter(dirAddress,true);

Now I want to add ip address of the local machine in the path... as...


string dirAddress = "\\192.168.15.96\\C:\\FTPTrace\\" + ipHeader.DestinationAddress.ToString() + ".txt";

but it raises the exception "A first chance exception of type 'System.NotSupportedException' occurred in mscorlib.dll"

Kindly guide me where am i wrong... ??

Plz help...

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by thines01
0

The drive letter will always need to come first IF your intention is to write it to a mapped drive.
Is the IP address part supposed to be a directory or part of the file name?
...or something else?

Edited by thines01: n/a

1

Check to ensure that \\192.168.15.96\C:\FTPTrace is accessible through windows explorer. I can guarantee that it isn't. You can't have a ':' in a network path after a drive number - try sharing your C drive - then try naming the share "C:" instead of the default "C". It doesn't work!

0

The drive letter will always need to come first IF your intention is to write it to a mapped drive.
Is the IP address part supposed to be a directory or part of the file name?
...or something else?

IP address is part of the file name... just as the drive is part of the
file name...

0

Like skatamatic said, the share name for the C:\ drive on the remote machine will not be C: (it is probably something like C$ or C). Check the remote machine to ensure it is sharing the C:\ drive, what its share name is, and the permissions (right-click -> properties -> sharing etc.). Also, you need 2 backslashes in front of a network address, since \\ is an escape character you could either do:

string dirAddress = "\\\\192.168.15.96\\C$\\FTPTrace\\" + ipHeader.DestinationAddress.ToString() + ".txt";

or:

string dirAddress = @"\\192.168.15.96\C$\FTPTrace\" + ipHeader.DestinationAddress.ToString() + ".txt";

Edited by nmaillet: n/a

0

Well, if it actually is on a remote machine and the current user has permission to the C drive (sharing is ebabled on the C drive), that will work.
You could also map a network drive to that location.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.