View previous topic :: View next topic |
Author |
Message |
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Wed Jan 30, 2008 10:20 am Post subject: Sending files to Recycle Bin or Trashcan |
|
|
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 |
|
|
hartung
Joined: 19 Jan 2008 Posts: 4 Location: Brazil
|
Posted: Thu Jan 31, 2008 4:35 am Post subject: Sending files to Recycle Bin or Trashcan |
|
|
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 |
|
|
hartung
Joined: 19 Jan 2008 Posts: 4 Location: Brazil
|
Posted: Thu Jan 31, 2008 4:42 am Post subject: Sending files to Recycle Bin or Trashcan |
|
|
Ops....
Remove the ' ~ "\0"' |
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Thu Jan 31, 2008 8:12 am Post subject: |
|
|
Oi, right back.
What if I don't use tango, yet? Is SHFILEOPSTRUCT part of tango? |
|
Back to top |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Thu Jan 31, 2008 8:45 am Post subject: |
|
|
jicman wrote: | Oi, right back.
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.
|
|
Back to top |
|
|
jicman
Joined: 22 Dec 2004 Posts: 298 Location: Rochester, NY
|
Posted: Thu Jan 31, 2008 9:38 am Post subject: |
|
|
Yep. Saw that. javascript:emoticon('') |
|
Back to top |
|
|
|