Home > Net >  How make this? The great god> o <
How make this? The great god> o <

Time:09-26

String filename="C \ \ Users \ \ 13374 \ \ Documents \ \ VisualStudio2015 2.0 \ \ \ \ Projects \ \ tuixiangzi pushed box 2.0 \ bin \ \ Debug \ \ Map" + n.T oString () + "info".
FileStream fs=new FileStream (filename, FileMode. Open, FileAccess. Read);
BinaryReader r=new BinaryReader (fs);

Untreated System. ArgumentException HResult=- 2147024809 Message=with illegal characters in Path, Source=mscorlib StackTrace: in the System. IO. Path. CheckInvalidPathChars (String Path, Boolean checkAdditional) in the System. IO. Path. The GetFileName (String Path) in the System. IO. FileStream.. ctor(String path, FileMode mode, FileAccess access) 在 推箱子2._0.Form1.ReadMap(Int32 n) 位置 C:\Users\13374\Documents\Visual Studio 2015\Projects\推箱子2.0\推箱子2.0\Form1.cs:行号 36 在 推箱子2._0.Form1.initdata() 位置 C:\Users\13374\Documents\Visual Studio 2015\Projects\推箱子2.0\推箱子2.0\Form1.cs:行号 53 在 推箱子2._0.Form1.Form1_Load(Object sender, EventArgs e) 位置 C:\Users\13374\Documents\Visual Studio 2015\Projects\推箱子2.0\推箱子2.0\Form1.cs:行号 58 在 System.Windows.Forms.Form.OnLoad(EventArgs e) 在 System.Windows.Forms.Form.OnCreateControl() 在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 在 System.Windows.Forms.Control.CreateControl() 在 System.Windows.Forms.Control.WmShowWindow(Message& M) in the System. Windows. Forms. Control. WndProc (Message& M) in the System. Windows. Forms. ScrollableControl. WndProc (Message& M) in the System. Windows. Forms. Form. WmShowWindow (Message& M) in the System. Windows. Forms. Form. WndProc (Message& M) in the System. Windows. Forms. Control. ControlNativeWindow. OnMessage (Message& M) in the System. Windows. Forms. Control. ControlNativeWindow. WndProc (Message& M) in the System. Windows. Forms. NativeWindow. DebuggableCallback (IntPtr hWnd, Int32 MSG, IntPtr wparam, IntPtr lparam) InnerException:

CodePudding user response:

The second line:
Box 2.0 \ bin \ \ Debug \ \ Map
Should be changed to:
2.0 box \ \ bin \ \ Debug \ \ Map

CodePudding user response:

String concatenation recommended or use string format.

CodePudding user response:

This problem should be the path you are directly copied to appearing in the code..

I also met a lot of time.. Very simple d: \ \ 1. TXT if manual to knock up it is no problem.

If from the resource manager or the path of the file itself copied the past suggests that there was a problem..

May is the coding system.

But this code in fact you should not be written as a fixed directory should use the
 
Var data=https://bbs.csdn.net/topics/file.readallbytes (System. Windows. Forms. Application. StartupPath + "\ \ Map \ " + I + "info");

To implement the

CodePudding user response:

Your ide has told you, it is a great god: path with
You put the into English, then 2.0 this take out,

CodePudding user response:

refer to 4th floor are nu month god reply:
your ide has told you, it is a great god: path of
You put the into English, then 2.0 this take out,

Changed or incorrect said illegal characters

CodePudding user response:

reference 5 floor FGJHFGHJKFF reply:
Quote: refer to 4th floor are nu month god reply:
your ide has told you, it is a great god: path of
You put the into English, then 2.0 this take out,

Changed or there is an error that a illegal characters


Try to add a string in front of the path filename=@ "XXXXXX";

CodePudding user response:

reference 5 floor FGJHFGHJKFF reply:
Quote: refer to 4th floor are nu month god reply:
your ide has told you, it is a great god: path of
You put the into English, then 2.0 this take out,

Changed or there is an error that a illegal characters

C ...
This disk c path clearly not ah, you,
The somebody else all is C: \

CodePudding user response:

Or I sent you to help me have a look at the code

CodePudding user response:

After changed, add @ can't find the file directly

CodePudding user response:

reference 1st floor datafansbj response:
the second line:
Box 2.0 \ bin \ \ Debug \ \ Map
Should be changed to:
2.0 box \ \ bin \ \ Debug \ \ Map

Is not the problem, this change doesn't work

CodePudding user response:

What is debugged the value of the filename? This question is very simple, should not be going to here,

CodePudding user response:

Error: in the System. IO. FileStream.. Ctor (String path, FileMode mode, FileAccess access) in box 2. _0. Form1. ReadMap (Int32 n)

CodePudding user response:

 
Try
{
Int n=1;
//string filename=@ "C: \ \ Users \ \ 13374 \ \ Documents \ \ VisualStudio2015 2.0 \ \ \ \ Projects \ \ tuixiangzi pushed box 2.0 \ bin \ \ Debug \ \ Map" + n.T oString () + "info";
The string filename=System.IO.Path.Com bine (System. AppDomain. CurrentDomain BaseDirectory, $" Map {n.T oString ()}. The info ");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related