ListView AfterLabelEdit Dosya Veya Klasör Adını Düzenle - CSharp


.

Kod


public static void AfterLabelEdit_DosyaVeyaKlasorAdiniDuzenle(
    object sender, LabelEditEventArgs e, ListView listView)
{
    //https://stackoverflow.com/a/47435544
    if (String.IsNullOrWhiteSpace(e.Label))
    {
        e.CancelEdit = true;
        //MessageBox.Show("Please enter a valid value.");
        return;
    }
    else
    {
        string eskiTamYol = SelectedItemUzerindenTamYolVer(listView);

        if (DosyaKlasor.TamYolDosyaMiKlasorMu(eskiTamYol) == TamYolTur.Dosya)
        {
            string dosyaTamYol =
                Path.Combine(Path.GetDirectoryName(eskiTamYol), e.Label);

            File.Move(eskiTamYol, dosyaTamYol);
        }
        else
        {
            string klasorTamYol =
                Path.Combine(Path.GetDirectoryName(eskiTamYol), e.Label);

            Directory.Move(eskiTamYol, klasorTamYol);
        }
    }
}

Etiketler
csharp