i got an error at line 11 to rename the directory(its old name is "0",i want to change to "1") when i ran the code as follow.
anybody can help me ?
main code:
1 private function void ftpRename()
2 {
3 URI = @"ftp://"+Server ip+"/0";
4 System.Net.FtpWebRequest ftp = GetRequest(URI);
5 //Set request to delete
6 ftp.Method = System.Net.WebRequestMethods.Ftp.Rename;
7 ftp.RenameTo = "/1";
8 try
9 {
10 //get response but ignore it
11 string str = GetStringResponse(ftp); ///error here!!!
12 }
13 catch (Exception)
14 {
15 return false;
16 }
17 }
18 //Get the basic FtpWebRequest object with the
19 //common settings and security
20 private FtpWebRequest GetRequest(string URI)
21 {
22 URI = @"ftp://" + URI;
23
24 FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
25
26 result.Credentials = GetCredentials();
27
28 result.EnableSsl = false;
29
30 result.KeepAlive = false;
31 // support for passive connections
32 result.UsePassive = true;
33 return result;
34 }
35
36 private string GetStringResponse(FtpWebRequest ftp)
37 {
38 //Get the result, streaming to a string
39 string result = "";
40 using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
41 {
42 long size = response.ContentLength;
43 using (Stream datastream = response.GetResponseStream())
44 {
45 using (StreamReader sr = new StreamReader(datastream, System.Text.Encoding.UTF8))
46 {
47 result = sr.ReadToEnd();
48 sr.Close();
49 }
50
51 datastream.Close();
52 }
53
54 response.Close();
55 }
56
57 return result;
58 }