Thursday 15 April 2010

asp.net - create txt file on desired path at runtime in c# -


I'm a newbie in C #. I have a problem, I want to create the file name IP address at runtime and write the data to those files. I am using this code for the purpose, but it is not working it is my exceoption:

  type 'System.NotSupportedException' first chance exception Mscorlibkdll < / Code> has occurred  

is not an exception:

  System.NotSupportedException: The format of the given path is not supported.   

And this is my code:

  System.Diagnostics.Debug.Write (content); Handler Beneficiaries (state buffer, 0, state object buffer size, 0, new async callback (readclawback), state); System.Diagnostics.Debug.WriteLine (read "{0} byte from socket. \ NData: {1}", content); String dir = @ "C: \ AppRecord"; If (! Directory.Exists (dir)) {Directory.CreateDirectory (dir); } File.WriteAllText (Path.Combine (dir, "logon" + handler.RemoteEndPoint.ToString () +), content "txt.");   

This stack trace:

  type the first time the 'System.NotSupportedException' exception System.Security.Util.StringExpressionSet in mscorlib.dll Systemic slidespace (string path, boolean is needed for flip cover) on system system occured On the system Security. Use Stringexpressseat Crest Listfrem Expression (string [] require string Buliyn. System. Security. Ad. IOPermissionkAddPathList file (file [IOPermissionAccess Access, Access Control Action Control, string] PathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) on System.Security.Permissions.FileIOPermission..ctor (using FileIOPermissionAccess, AccessControlActions control, string [] pathList, Boolean checkForDuplicates, Boolean needFullPath) (string path System.IO.FileStream.Init, FileMode mode, using FileAccess, Int32 a Ikar, Boolean useRights, fileshare share, Int32 BufferSize, FileOptions option, SecAttrs, string msgPath, Boolean bFromProxy) System.IO.StreamWriter on SECURITY_ATTRIBUTES. System.IO.StreamWriter..ctor (String path, Boolean) on System.IO.FileStream KCreateFile (string path, Boolean append) on. Straighter (string path, Failmod mode, file access access, Failseyr share, brick enclosed 32 buffer size, file option) encoding encoding, Int32 on System.IO.StreamWriter..ctor BufferSize) (String Path, Boolean Attached, Encoding Encoding) on ​​System.IO.File.WriteAllText (St Ring path, string content, encoding encoding) at System.IO. File.WriteAllText (string path, string material ServerWService.Service1.AsynchronousSocketListener.ReadCallback (IAsyncResult ar) on)    

I think the handler. RemoteEndPoint will return with the port separated by an IP address: but you have : A file on windows name can not be, for example, Any other characters like it have to be replaced, such as underscores.

No comments:

Post a Comment