I have a code written in C # (.Net 3.5) with this code.
using the system; Using System.Net; String strurI = String.Format ("ftp: // x {0} ftp /% 2F '{1}'", parm1, parm2); FtpWebRequest ftp = (FtpWebRequest) FtpWebRequest.Create (Struia); Ftp.Proxy = null; Ftp.KeepAlive = True; Ftp.UsePassive = false; Ftp.UseBinary = false; Ftp.Credentials = New network credentials ("UID", "Pass"); Ftp.Method = WebRequestMethods.Ftp.DownloadFile; FtpWebResponse response = (FtpWebResponse) ftp.GetResponse (); ... I have translated it into F # (.Net 4.0) for use in my application.
Open System.Net let uri = sprintf "Ftp: // x% sftp / %% 2F '% s'" Parm 1 Parm 2 to ftp = FtpWebRequest.Create (uri) :? & Gt; FtpWebRequest ftp.Credentials & lt; - New network credentials ("UID", "Pass") ftp.Method & lt; - WebRequestMethods.Ftp.DownloadFile ftp.Proxy & lt; - Fingerprint = ftp.GetResponse ():? & Gt; FtpWebResponse ... At this point, FSI complains.
System.Net.WebException: The remote server returned an error: (550) File not found file unavailable (eg, no access).
Still the C # application runs and downloads the file successfully. What am I missing in F # (apart from assets, which are not in 4.0 i.e. KeepAlive, UsePassive, and UseBinary)?
code may be errors, I have F # compiler is not yet
Open System Open System Reflections open system.Net let switch_to_legice_mode_ = let wtype = typeof & lt; FtpWebRequest & gt; Let mfield = wtype.GetField ( "m_MethodInfo", BindingFlags.NonPublic ||| Baindingflagkinstens), or a doubling of mtype = mfield.FieldType = mtype.GetField ( "KnownMethodInfo", BindingFlags.Static ||| .BindingFlags.NonPublic) Repeat = Gurgaon.Gate Value (empty):? & Gt; Array let flags = mtype.GetField ( "Flags", BindingFlags.NonPublic ||| BindingFlags.Instance) Let knarr the Frem_vl = 0x100, temporary ff = flags.GetValue (f) :? & Gt; Int FF & LT; - FF ||| Flag_val flags.SetValue (f, ff) uri = sprintf "ftp: //x% sftp / %% 2F '% s'" parm1 parm2 do switch_to_legacy_mode () // Call one time before making an FTP request ftp = FtpWebRequest . Make (Yuri):? & Gt; FtpWebRequest ftp.Credentials & lt; - New network credentials ("UID", "Pass") ftp.Method & lt; - WebRequestMethods.Ftp.DownloadFile ftp.Proxy & lt; - Fingerprint = ftp.GetResponse ():? & Gt; FtpWebResponse Source:
The cause of this problem is due to a behavior change in the System.Net.FtpWebRequest class in the .Net Framework 4. There are systems The .Net.FtpWebRequest class is a change made in Net Framework 4 to simplify the use of CWD protocol commands from NetWorldWork 3.5. The new implementation of the System.Net.FtpWebRequest class sends additional CWD commands before issuing the actual order requested by the user and sends the requested command instead. For fully RFC compliant FTP servers, this should not be an issue, however for non-fully RFC-compliant servers, you will see these types of errors.
No comments:
Post a Comment