Topic "Rename File - Overwrite Existing"

Author Message
Yellow
[View user's profile]

Joined: 2013-02-20
Posts: 5
Hi

In .net is it possible to rename a file and if that file already exists, overwrite it automatically?

Cheers
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
So you want Session.MoveFile to remove target file, if that already exists, correct? It's not possible, unless the server does it for you, what it usually does not.

Why don't you use Session.FileExists and Session.RemoveFiles first?
http://winscp.net/eng/docs/library_session_fileexists
http://winscp.net/eng/docs/library_session_removefiles
Yellow
[View user's profile]

Joined: 2013-02-20
Posts: 5
Hi

Thanks for the reply. Basically I want to upload a file name 'MyFile'. Then rename it to 'MyNewFile'. If 'MyNewFile' already exists, then have an option to overwrite the existing 'MyNewFile'.

I realise I can delete the existing file first, that's not a problem. But I found this thread, which suggests such a rename feature exists, unless I am not understanding it: http://winscp.net/forum/viewtopic.php?t=25

Cheers
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
That's for GUI only.
_________________
Martin Prikryl
Yellow
[View user's profile]

Joined: 2013-02-20
Posts: 5
No worries. Thanks for letting me know.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License