C# Upload file with no extension -


i have got following code, need upload multiple files don't have extension/type assigned them. following code below works, not on these files it's trying make file example called: ftp.server/file

here code:

using system; using system.collections.generic; using system.linq; using system.text; using system.io; using system.net; using system.threading.tasks;  namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             string sourcefilepath = @"path"; // e.g. “d:/test.docx”             string ftpurl = @"ftp"; // e.g. ftp://serverip/foldername/foldername             string ftpusername = @"user"; // e.g. username             string ftppassword = @"pass"; // e.g. password              string[] filepaths = directory.getfiles(sourcefilepath);              // object used communicate server.             foreach (string filename in filepaths)             {                 ftpwebrequest request = (ftpwebrequest)webrequest.create(ftpurl + path.getfilename(filename));                 request.method = webrequestmethods.ftp.uploadfile;                  // example assumes ftp site uses anonymous logon.                 request.credentials = new networkcredential(ftpusername, ftppassword);                  // copy contents of file request stream.                 streamreader sourcestream = new streamreader(sourcefilepath);                 byte[] filecontents = encoding.utf8.getbytes(sourcestream.readtoend());                 sourcestream.close();                 request.contentlength = filecontents.length;                  stream requeststream = request.getrequeststream();                 requeststream.write(filecontents, 0, filecontents.length);                 requeststream.close();                  ftpwebresponse response = (ftpwebresponse)request.getresponse();                  console.writeline("upload file complete, status {0}", response.statusdescription);                  response.close();             }         }     } } 

the files iphone backup, iphone backups don't give files extensions need work around.

the solution found copy files , add dummy extension.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -