473,383 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Clipboard - How to determine file is cut or copied ?


Hi all,
I encountered a serious problem while working with
clipboard class in VB.NET.
I want to simulate cut-copy-paste operation with
my application and Windows Explorer.
User can copy files from Explorer and paste it into
my application & vice-a-versa.
My question is-
How can I determine if user has copied or cut the files
from Windows Explorer? I want to differentiate cut & copy.
I am using clipboard class to handle all this.

Please help,

Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
8 9782
Unfortunately, you can't, because the Clipboard object just carries the
data, it's explorer that decides whether or not to move the file, or copy
the file.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Dinesh Jain" <di*******@hotmail.com> wrote in message
news:ed*************@TK2MSFTNGP09.phx.gbl...
:
: Hi all,
: I encountered a serious problem while working with
: clipboard class in VB.NET.
: I want to simulate cut-copy-paste operation with
: my application and Windows Explorer.
: User can copy files from Explorer and paste it into
: my application & vice-a-versa.
: My question is-
: How can I determine if user has copied or cut the files
: from Windows Explorer? I want to differentiate cut & copy.
: I am using clipboard class to handle all this.
:
: Please help,
:
: Thanks in advance,
:
: -Regards,
: Dinesh
:
:
:
: *** Sent via Developersdex http://www.developersdex.com ***
: Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #2
Hi Tom,
Thnaks for the reply.
I searched under MSDN and came to know that when
we cut files from explorer and paste inside our
application, we need to send some confirmation to the
explorer about the paste opartion is completed or not.
But I am not able to find how to implement it in VB.NET.
Pls. search for "Handling Shell Data Transfer Scenarios"
in MSDN.

Please help,

Thanks in advance,

-Regards,
Dinesh
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

All experts,
No Answer for this question ?
I want to programatically cut a file from VB.NET.
Please help,

Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
Cor
Hi,
Therefore you need no expert,
You can try it yourself.
Copy files from explorer.
Open the notepad and try to paste.
Nothing there I think.
So it seems if the clipboard is not used

That means for me that it looks if Explorer uses the following system.
When you copy, it clears the clipboard.
It saves the data somewhere (inclusive a copy or cut parameter)
When you paste on another place I think it does the following.
If the parameter is "cut it starts using the "file move" method and else
when it is "copy" it uses the "file copy" method

So when you want to do something to simulate that, I think you need the
whole process.
(And not such a big job to do with vb.net)

When you want to know where explorer saves this data, that is another
question, but I don't believe that is VB.net language, more a Windows
question. It can be for every version different (although you only have to
know it of course for systems that use the framework).

I hope this helps you further on the route.

Cor

Nov 20 '05 #5
Hi Cor,

No. Unfortunately you are wrong. The Clipboard *is* used. You can't paste
anything into notepad because it's not text in the clipboard, it's another
form of data. Also, Windows just doesn't copy the contents of the file into
the clipboard, it copies the location of the file and what it needs to do to
it there, and when the operation is completed, e.g. what Dinesh is trying to
do (tell explorer that the operation has completed), then explorer will
either A. Copy the file to the new location, B. Move the file to the new
location.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
: Hi,
: Therefore you need no expert,
: You can try it yourself.
: Copy files from explorer.
: Open the notepad and try to paste.
: Nothing there I think.
: So it seems if the clipboard is not used
:
: That means for me that it looks if Explorer uses the following system.
: When you copy, it clears the clipboard.
: It saves the data somewhere (inclusive a copy or cut parameter)
: When you paste on another place I think it does the following.
: If the parameter is "cut it starts using the "file move" method and else
: when it is "copy" it uses the "file copy" method
:
: So when you want to do something to simulate that, I think you need the
: whole process.
: (And not such a big job to do with vb.net)
:
: When you want to know where explorer saves this data, that is another
: question, but I don't believe that is VB.net language, more a Windows
: question. It can be for every version different (although you only have to
: know it of course for systems that use the framework).
:
: I hope this helps you further on the route.
:
: Cor
:
:
:
Nov 20 '05 #6
Cor
Tom,

You are totally right.
My explanation was written in a popular way and even with fundamental
errors.

Because of your message I did really investigate it and as deep as I can go.
(That is not so deep). The results do not change in my opinion.

It seems if explorer does the entire thing intern and does not even save
things.
I did try the following things:
- What is happening if I copy and cut (that we know)
- What is happening when I cut and close all explores open an explorer and
paste on another place. The result is that there are two files.
- What happens if I cut in one explorer, open another, close the first, and
paste in the second.
My result was that I had one file.

So my conclusion is that explorer not even saves the information about a
"cut", it is in a public part of the explorer.exe program itself when it is
running.

I've never seen some automation on it so you really have to know everything
of all versions to realize what is asked I think.

I tested what happened when I did a cut in explorer and then a copy from the
clipboard
The files which were cut where not thrown away or brought to the trash bin.

So the conclusion stays the same, now maybe something more professional.

My test program is beneath, with that you can copy files from the clipboard.

\\\\\
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.FileDrop) Then
Dim tom As String() =
DirectCast(iData.GetData(DataFormats.FileDrop), String())
Dim i As Integer
Me.FolderBrowserDialog1.ShowDialog()
For i = 0 To tom.Length - 1
If
System.IO.File.Exists(Me.FolderBrowserDialog1.Sele ctedPath &
tom(i).Substring(tom(i).LastIndexOf("\"))) Then
System.IO.File.Move(Me.FolderBrowserDialog1.Select edPath
& tom(i).Substring(tom(i).LastIndexOf("\")), _
Me.FolderBrowserDialog1.SelectedPath &
"temptemptemp.temp")
End If
System.IO.File.Copy(tom(i),
Me.FolderBrowserDialog1.SelectedPath &
tom(i).Substring(tom(i).LastIndexOf("\")))
If
System.IO.File.Exists(Me.FolderBrowserDialog1.Sele ctedPath &
"temptemptemp.temp") Then

System.IO.File.Delete(Me.FolderBrowserDialog1.Sele ctedPath &
"temptemptemp.temp")
End If
Next
End If
End Sub
//////////

Again a nice test
Cor


Nov 20 '05 #7
Hi Tom,

I've stayed quiet on this one because I don't have a solution - still
researching - but now I must speak, at least as far as I understand this
stuff.

Explorer sends the file names or a list of file names. It <does> give an
indication of whether it's a move (cut) or copy operation. It's up to the
receiving application to actually do the job with the files - not Explorer. If
the job is a copy then the receiving app copies the file(s) and the job's
done. If it's a move operation, the receiving app copies the file(s) and then
sends a message <back> to Explorer to say that the copies were made. Explorer
then does the <delete>.

The problem for Dinesh is that the .NET Clipboard doesn't (as far as I can
work out) send <back> to the sending application. It's possible to tell that a
move is required but not to tell Explorer that it's been done. The
documentation is, as usual :-(, full of trivial inter-app examples (how to
send text), but doesn't show the hard stuff - copying files to/from Explorer.

It's possible to do what Dinesh wants by ignoring the Clipboard class
(perhaps) and getting into the API (certainly). The 'how' is still beyond me.
:-(

Regards,
Fergus
Nov 20 '05 #8
Cor
Fergus,
I dont believe that explorer sends a message that it has a cut/copy.
It keeps it for itself as long as it is alive in memory, and then it is
flushed I think.
Explorer is an exe no dll.
Try it yourself what I was experimenting.
Cor
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sami Viitanen | last post by:
Hello, How can I check if a file is binary or text? There was some easy way but I forgot it.. Thanks in adv.
4
by: neo | last post by:
I got a mdf file from my co-worker who just stopped SQL server and delete ldf file and give me a mdf file. if it was detached, it would work fine but it was just copied. Is there any way to...
0
by: Morten Overgaard | last post by:
Hi Anybody knows how to save an "embedded object" from the clipboard to a file with the correct filename ( can it be extracted from the clipboard ??) And How do I do it vice versa... ...
10
by: Marc Jennings | last post by:
Hi there, Can anyone point out any really obvious flaws in the methodology below to determine the likely encoding of a file, please? I know the number of types of encoding is small, but that is...
2
by: steve | last post by:
Hi All I have a program which takes photos of members using a web cam, then saves them as bitmap files The bitmap is used by a Picturebox to display the photo and clicking on a button enables...
3
by: Mark Gibson | last post by:
Is there an equivalent to the unix 'file' command? $ file min.txt min.txt: ASCII text $ file trunk trunk: directory $ file compliance.tgz compliance.tgz: gzip compressed data, from Unix ...
0
by: Dist | last post by:
Hi, I would just like to know if there is a way to determine if a specific file is being copied in windows using .net. For example, I got a service running in the background to check all files,...
23
by: Over | last post by:
Hi it's possible with language C, (Mingw or Djgpp) copying the clipboard of WinXp into file.txt? which function must be use. Thanks
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.