Click here to Skip to main content
14,660,101 members
Home » Discussions » C#
   

C#

 
SuggestionRe: Date compare Pin
Richard Deeming28-Apr-20 0:40
mveRichard Deeming28-Apr-20 0:40 
AnswerRe: Date compare Pin
Carlos5828-Apr-20 2:23
MemberCarlos5828-Apr-20 2:23 
QuestionRename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 1:13
MemberSriram Valluri27-Apr-20 1:13 
AnswerRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 1:21
mveZurdoDev27-Apr-20 1:21 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 2:15
MemberSriram Valluri27-Apr-20 2:15 
GeneralRe: Rename files in WinScp Directory using C# Pin
ZurdoDev27-Apr-20 2:27
mveZurdoDev27-Apr-20 2:27 
AnswerRe: Rename files in WinScp Directory using C# Pin
Jin Vincent Necesario27-Apr-20 2:36
professionalJin Vincent Necesario27-Apr-20 2:36 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 8:07
MemberSriram Valluri27-Apr-20 8:07 
below is my code.




  // Setup session options
                SessionOptions sessionOptions = new SessionOptions
                {
                    Protocol = Protocol.Sftp,
                    HostName = "ap*****",
                    UserName = "****",
                    Password = "******",
                    SshHostKeyFingerprint = "*******"
                };

                using (Session session = new Session())
                {
                    // Connect

                    session.ExecutablePath = @"WinSCP.exe path";

                    session.Open(sessionOptions);


                    List<RemoteFileInfo> files =
       session.EnumerateRemoteFiles(
           MonitorDirectory, FileSearchPattern, EnumerationOptions.None)
           .ToList();

                    DateTime now = DateTime.Today;

                    ReportMonth = now.ToString("MMM").ToUpper();

foreach (RemoteFileInfo fileInfo in files)
    {

------------------------------have to do renaming of the file here---------------------------

          if (fileInfo.FullName.Contains(GetClientID))
              {
                   if (fileInfo.Length > ThresholdValue)
                      {
          FileModifiedDate = fileInfo.LastWriteTime.ToString("yyyyMM", CultureInfo.InvariantCulture);

              if (GetReportDateYM == FileModifiedDate || fileInfo.FullName.Contains(ReportMonth))
                                {
                                    FileName = fileInfo.FullName;



                                    Dts.Variables["User::FileName"].Value = FileName;
                                    Dts.Variables["User::FileDate"].Value = FileModifiedDate;
                                    Dts.TaskResult = (int)ScriptResults.Success;
                                    break;
                                }

                            }


                        }


So here I have a directory in remote server and I am accessing it through WinSCP tool. requirement is to rename the files insider this remote directory. I can read each and every file name but I am not able to find rename function here.
AnswerRe: Rename files in WinScp Directory using C# Pin
Luc Pattyn27-Apr-20 8:21
sitebuilderLuc Pattyn27-Apr-20 8:21 
GeneralRe: Rename files in WinScp Directory using C# Pin
Sriram Valluri27-Apr-20 21:21
MemberSriram Valluri27-Apr-20 21:21 
QuestionMulticombobox in datagridview c# Pin
Member 1347974626-Apr-20 16:12
MemberMember 1347974626-Apr-20 16:12 
AnswerRe: Multicombobox in datagridview c# Pin
OriginalGriff26-Apr-20 19:25
mveOriginalGriff26-Apr-20 19:25 
QuestionAccess Rights Management Pin
Member 1481258225-Apr-20 13:13
MemberMember 1481258225-Apr-20 13:13 
AnswerRe: Access Rights Management Pin
OriginalGriff25-Apr-20 20:09
mveOriginalGriff25-Apr-20 20:09 
AnswerRe: Access Rights Management Pin
Gerry Schmitz26-Apr-20 6:54
mveGerry Schmitz26-Apr-20 6:54 
AnswerRe: Access Rights Management Pin
Mycroft Holmes26-Apr-20 12:21
professionalMycroft Holmes26-Apr-20 12:21 
QuestionIssue while solving 100 Doors Kata Problem Pin
User-862169524-Apr-20 21:51
MemberUser-862169524-Apr-20 21:51 
AnswerRe: Issue while solving 100 Doors Kata Problem Pin
OriginalGriff24-Apr-20 22:06
mveOriginalGriff24-Apr-20 22:06 
GeneralRe: Issue while solving 100 Doors Kata Problem Pin
User-862169524-Apr-20 22:21
MemberUser-862169524-Apr-20 22:21 
GeneralRe: Issue while solving 100 Doors Kata Problem Pin
OriginalGriff24-Apr-20 22:31
mveOriginalGriff24-Apr-20 22:31 
QuestionRe: Issue while solving 100 Doors Kata Problem Pin
Richard MacCutchan24-Apr-20 22:09
mveRichard MacCutchan24-Apr-20 22:09 
AnswerRe: Issue while solving 100 Doors Kata Problem Pin
Gerry Schmitz25-Apr-20 11:52
mveGerry Schmitz25-Apr-20 11:52 
QuestionSQL Connection in Visual Studio Pin
Member 1481258224-Apr-20 12:25
MemberMember 1481258224-Apr-20 12:25 
AnswerRe: SQL Connection in Visual Studio Pin
Eddy Vluggen24-Apr-20 12:40
professionalEddy Vluggen24-Apr-20 12:40 
AnswerRe: SQL Connection in Visual Studio Pin
Matt Slay24-Apr-20 16:28
MemberMatt Slay24-Apr-20 16:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.