0
I have an image in a folder and I wanted to change its name only
someone can help me
thank you
example:
original name.jpg
went to:
desired name.jpg
0
I have an image in a folder and I wanted to change its name only
someone can help me
thank you
example:
original name.jpg
went to:
desired name.jpg
3
Use the System.IO.File.Move
System.IO.File.Move("nomeoriginal.jpg", "nomepretendido.jpg");
Source: https://stackoverflow.com/questions/3218910/rename-a-file-in-c-sharp
0
A safe way to do this is to make a copy of your source image, to your target image already with the name you want to use in the source image. For example:
private void copyimage()
{
//Caminho padrão para as imagens.(Mude para o diretório aonde suas imagens estão armazenadas).
string sCaminho = Directory.GetCurrentDirectory() + @"\PastaImagens\";
//Imagem de origem.
string sImgOrigem = sCaminho + "NomeImgOrigem.jpg";
//Imagem com novo nome.
string sImgDestino = sCaminho + "NomeImgDestino.jpg";
//Copia a imagem para mesma pasta, porém com o nome diferente.
File.Copy(sImgOrigem, sImgDestino);
//Se tudo deu certo, deleta a imagem de origem.
File.Delete(sImgOrigem);
}
In case it worked, in the end we delete our source image. This gives a greater security so we do not lose the image for some other problem, especially when we use it in a loop.
-1
insira o código aqui
using System.IO;
namespace RenomeandoNomesDasFotos
{
class Program
{
static void Main(string[] args)
{
Directory.Move("C:\Imagens\foto.png", "C:\Imagens\fotoRenomeada.png");
}
}
}
Browser other questions tagged c# asp.net
You are not signed in. Login or sign up in order to post.
Remembering that the parameters should be the full path of the files, not just the name.
– Jéf Bueno
Well noted @jbueno
– PauloHDSousa
thank you worked very well
– Luis oliveira
@Luisoliveira You can mark this answer as correct by marking the ✓ just below the arrows to vote...
– Jéf Bueno