Winscp RemoteFileInfo how to convert the file into byte array in C# .net
I am in trouble over on issue,I have to read a file content or read the file bytes and need to store in it our database.
How to do it in WinScp in .net System.Io.File we can simply call File.ReadAllBytes(file).
How to do it in Winscp RemoteFileInfo.
Sample code .
using (Session session = new Session())
{
session.Open(sessionOptions);
if (objFTP.RequestFor == "FR")
{
//sDirectoryPath.Append(objFTP.ReferenceNo);
directory = session.ListDirectory(basePath+objHCSAuthenticate.Source+"/"+objFTP.ReferenceNo); // Creation winscp Directory
}
else
{
//sDirectoryPath.Append(objFTP.PreAuthNo);
directory = session.ListDirectory(basePath + objHCSAuthenticate.Source + "/" + objFTP.PreAuthNo); // Creation winscp Directory
}
}
foreach(RemoteFileInfo fileInfo in directory.Files)
{
string sFileNAme = string.Empty;
string sDocShortCode = string.Empty;
string sDocType = string.Empty;
// sFileNAme = Path.GetFileName(file1);
sFileNAme = fileInfo.Name;
string[] FileNameArray = sFileNAme.ToString().Split('_');
sDocShortCode = FileNameArray[1]; //Get DocumentShortCode
sDocType = GetDocumentType(sDocShortCode);
//byte[] bytes = File.ReadAllBytes(file1);
byte[] bytes =System.Text.Encoding.UTF8.GetBytes(fileInfo.GetHashCode);
}
How to do it in WinScp in .net System.Io.File we can simply call File.ReadAllBytes(file).
How to do it in Winscp RemoteFileInfo.
Sample code .
using (Session session = new Session())
{
session.Open(sessionOptions);
if (objFTP.RequestFor == "FR")
{
//sDirectoryPath.Append(objFTP.ReferenceNo);
directory = session.ListDirectory(basePath+objHCSAuthenticate.Source+"/"+objFTP.ReferenceNo); // Creation winscp Directory
}
else
{
//sDirectoryPath.Append(objFTP.PreAuthNo);
directory = session.ListDirectory(basePath + objHCSAuthenticate.Source + "/" + objFTP.PreAuthNo); // Creation winscp Directory
}
}
foreach(RemoteFileInfo fileInfo in directory.Files)
{
string sFileNAme = string.Empty;
string sDocShortCode = string.Empty;
string sDocType = string.Empty;
// sFileNAme = Path.GetFileName(file1);
sFileNAme = fileInfo.Name;
string[] FileNameArray = sFileNAme.ToString().Split('_');
sDocShortCode = FileNameArray[1]; //Get DocumentShortCode
sDocType = GetDocumentType(sDocShortCode);
//byte[] bytes = File.ReadAllBytes(file1);
byte[] bytes =System.Text.Encoding.UTF8.GetBytes(fileInfo.GetHashCode);
}