English 中文(简体)
我如何在C#.NET中确定LRECL?
原标题:How do I set the LRECL in C#.NET?
  • 时间:2010-05-27 13:35:17
  •  标签:
  • c#
  • ftp

我一直在试图从内联网向我所知的AS400盗窃一个 d。 报给我的错误是:“一线或多条线被拖走”,行政部门说,档案上有256条线,长度各栏。 我在网上找到这一解释:

我们必须确定违约情况,因为没有关于档案的具体内容。 拖欠的RECFM为V,LRECL为256。 这意味着,SAS将扫描参考CR &的投入记录;LF告诉我们,我们是EOR。 如果在LRECL的限额内发现标记,SAS将数据从LRECL值中删除到记录结束,并向这些记录员发出一个信息,即“一个或一个以上线已经缩小”。

因此,我需要设立LRECL。 我如何在C# NET中这样做?

            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
            ftp.Credentials = new NetworkCredential(user, pwd);

            ftp.KeepAlive = false;
            ftp.UseBinary = false;  
            ftp.Method = WebRequestMethods.Ftp.UploadFile;

            FileStream fs = File.OpenRead(inputfilepath + ftpfileName);
            byte[] buffer = new byte[fs.Length];
            fs.Read(buffer, 0, buffer.Length);
            fs.Close();

            Stream ftpstream = ftp.GetRequestStream();

            int i = 0;
            int intBlock = 1786;
            int intBuffLeft = buffer.Length;

            while (i < buffer.Length)
            {
                if (intBuffLeft >= 1786)
                {
                    ftpstream.Write(buffer, i, intBlock);
                }
                else
                {
                    ftpstream.Write(buffer, i, intBuffLeft);
                }
                i += intBlock;
                intBuffLeft -= 1786;
            }
           ftpstream.Close();
问题回答

1786 是256。

我认为,你需要把溪流的内容与“偷窃网”分开。

StreamReader sourceStream = new StreamReader(fileName);
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();

ftp.ContentLength = fileContents.Length;
Stream ftpstream = ftp.GetRequestStream();
ftpstream.Write(fileContents, 0, fileContents.Length);
ftpstream.Close();




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签