FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sending files to Recycle Bin or Trashcan

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Wed Jan 30, 2008 10:20 am    Post subject: Sending files to Recycle Bin or Trashcan Reply with quote

Greetings and salutations from Rochester, NY.

Is there a way, using DFL to send a file to the recycle bin or trashcan? I don't want to delete it, but instead send it to the recycle bin?

thanks,

jose
Back to top
View user's profile Send private message
hartung



Joined: 19 Jan 2008
Posts: 4
Location: Brazil

PostPosted: Thu Jan 31, 2008 4:35 am    Post subject: Sending files to Recycle Bin or Trashcan Reply with quote

Quote:
Greetings and salutations from Rochester, NY.

"Oi" from Brazil.

Quote:
Is there a way, using DFL to send a file to the recycle bin or
trashcan? I don't want to delete it, but instead send it to the recycle bin?


I don't know if there is a way to do this only with DFL.
But I think this do what you want.

Code:
/**
 * Author: Christian Hartung
 */
module trash;

import tango.sys.Common;
import tango.stdc.stringz;

import dfl.all;

class Frm : Form
{
    this()
    {
        super();
       
        with(btn = new Button())
        {
            parent = this;
            location = Point(10, 10);
            text = "Delete";
            click ~= &delFile;
        }
       
        with(dlg = new OpenFileDialog())
        {
            multiselect = false;
            checkFileExists = true;
            title = "Select a file to delete";
        }
       
        text = "Send Files to Recycle Bin";
        size = Size(150, 150);
    }
   
    package void delFile(Object sender, EventArgs ea)
    {
        if(dlg.showDialog != DialogResult.OK)
            return;
       
        SHFILEOPSTRUCT s;
       
        with(s)
        {
            wFunc = 0x0003; // delete
            pFrom = toStringz(dlg.fileName ~ "\0");
            fFlags = 0x0040 | 0x0010; /* allow undo (send to Recycle Bin) |
                                         Don't prompt the user |
                                         don't create progress/report */
        }
       
        SHFileOperation(&s) ;
    }
   
    private Button btn;
    private OpenFileDialog dlg;
}

void main()
{
    try
    {
        Application.run(new Frm());
    }
    catch(Exception e)
    {
        msgBox(e.toString());
    }
}
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
hartung



Joined: 19 Jan 2008
Posts: 4
Location: Brazil

PostPosted: Thu Jan 31, 2008 4:42 am    Post subject: Sending files to Recycle Bin or Trashcan Reply with quote

Ops....

Remove the ' ~ "\0"'
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Jan 31, 2008 8:12 am    Post subject: Reply with quote

Oi, right back. Smile

What if I don't use tango, yet? Is SHFILEOPSTRUCT part of tango?
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Thu Jan 31, 2008 8:45 am    Post subject: Reply with quote

jicman wrote:
Oi, right back. Smile

What if I don't use tango, yet? Is SHFILEOPSTRUCT part of tango?
It's actually part of Windows, but I suppose you already know that by now since you've seen digitalmars.D.learn:10963 and digitalmars.D.learn:10964.

Wink
Back to top
View user's profile Send private message AIM Address
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Jan 31, 2008 9:38 am    Post subject: Reply with quote

Yep. Saw that. javascript:emoticon('Laughing')
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group