Home > Net >  Be urgent!!!! O great god!!!!!!!!!! Online etc.! C # IO. FileStream error have illegal characters in
Be urgent!!!! O great god!!!!!!!!!! Online etc.! C # IO. FileStream error have illegal characters in

Time:11-12

This is I wrote in the FTP client to download the server directory function

Private void DownloadFolder (string folderPath, string downloadPath, string folderName)
{
DownloadPath=downloadPath + "\ " + folderName;
+ downloadPath setOPERATE_INFO (" new folder path ");
Directory. CreateDirectory (downloadPath);
String [] FileList=Dir (folderPath);
for (int i=0; I & lt; FileList. Length - 1; I++)
{
String ndownloadPath=downloadPath + "\ " + FileList [I];
SetOPERATE_INFO (" download file path: "+ ndownloadPath);
If (FileList [I] the Contains (". "))
{
SetOPERATE_INFO (" file "+ FileList [I]);
String afolderPath=folderPath + "\ " + FileList [I];
SetOPERATE_INFO (" now the source download location "+ afolderPath);
The string fileName=FileList [I];
OpenDataPort ();//open data port
Cmd_Line="RETR" + afolderPath + CRLF.//copy the file command
BinData=https://bbs.csdn.net/topics/System.Text.Encoding.Default.GetBytes (Cmd_Line. ToCharArray ());
Cmd_Stream. Write (BinData, 0, BinData. Length);//written instructions
GetStatus ();//get the information



//this is a problem I found after the output to the operating information box debugging with
SetOPERATE_INFO (" there is a problem of path "+ ndownloadPath);

//the problem in this
FileStream FSTRM=new FileStream (ndownloadPath, FileMode OpenOrCreate);//used to download a file is written to computer



Byte [] fbytes=new byte [1030].
Int CNT=0;
While ((CNT=Data_Stream. Read (fbytes, 0, 1024)) & gt; 0)//flow data from the network (binary form)
{
FSTRM. Write (fbytes, 0, CNT);//write open file flow
}
FSTRM. Close ();//close the file flow
CloseDataPort ();//close port
Flush_right ();//refresh file list
SetOPERATE_INFO (" successful download file: "+ fileName);

}
The else
{

String newfolderPath=folderPath + "\ " + FileList [I];
DownloadFolder (newfolderPath downloadPath, FileList [I]);
SetOPERATE_INFO (" folder "+ FileList [I]);
}
}
return;
}




This is to run the function interface after
The path of the wrong statements output operation information bar at the bottom right, is very strange, clearly the path of the output no illegal character ah...

CodePudding user response:

Path before the space

CodePudding user response:

refer to 1st floor met the goddess response:
path before the space

Do you mean have a problem where the path is, in the operation information add the column space is late

CodePudding user response:

File names don't oneself use "+" to joining together, you should use System.IO.Path.Com bine method, can avoid the environmental change, caused by a slip of the pen and so on questions,

CodePudding user response:

Dir get list and directory, use the Contains (". ") to determine whether the file is wrong, because some files may be no extensions without ". "; And some directories can take ". ", as well as, a ". "said the current directory, two points".. "Said the superior directory, file name must be illegal

CodePudding user response:

Try using the @ symbol, the PAth with a + connection symbol sometimes complains,
  •  Tags:  
  • C#
  • Related