2 Comments

  1. Raj

    WPF application not works for this code when i drag to explorer or folder , but winforms works, any idea, windows 10

  2. Sona

    Hi,

     

    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

    private void DragImage()
    {
        // Create temp file
        var tempFilePath = Path.Combine(Path.GetTempPath(), String.Format(“{0}.jpg”, “test”));
        pictureBox1.Image.Save(tempFilePath, ImageFormat.Jpeg);
        // Prepare the data object
        string[] files = { tempFilePath };
        var data = new DataObject(DataFormats.FileDrop, files);
        data.SetData(DataFormats.Text, files[0]);
        // Perform dragdrop
        DoDragDrop(data, DragDropEffects.Copy);
        // Delete the temp file
        File.Delete(tempFilePath);
    }

    i have done same as shown..but temp file is getting created in the specified path. but not dropping the file to desktop. Please help

Leave a Reply

Your email address will not be published.

*