473,382 Members | 1,766 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,382 software developers and data experts.

drag-drop from outlook problem

Hi all,
I've got a half-functioning drag-drop from outlook app running.
I can get the name of the message from the FileGroupDescriptor part, but
whenever I try to get the FileContents part, I allways get Nothing back.
I've posted my code below - I hope someone here has a solution to this.

Cheers
Thomas

Private Sub Label1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles Label1.DragDrop

Dim header As IO.MemoryStream

Dim data As IO.MemoryStream

Dim fs As IO.FileStream

Dim filePath As String = ""

Dim fileName As String = ""

' check the formats supported

Dim s() As String

Dim sFormat As String

s = e.Data.GetFormats

For Each sFormat In s

Me.ListBox1.Items.Add("Supported format: " & sFormat)

Next

' get the file group descriptor, for the file name

header = CType(e.Data.GetData("FileGroupDescriptor", False),
IO.MemoryStream)

header.Position = 76

Do While True

Dim l As Integer = header.ReadByte()

If (l = 0) Then Exit Do

fileName &= Convert.ToChar(l).ToString()

Loop

If fileName.Length = 0 Then Return

Me.ListBox1.Items.Add("Object dropped: " & fileName)

' get the actual dropped object

data = CType(e.Data.GetData("FileContents", False), IO.MemoryStream)

If Not data Is Nothing Then

Try

' get the data as a byte array

Dim b(data.Length) As Byte

data.Position = 0

data.Read(b, 0, data.Length)

' save the byte array to file

filePath = "D:\" + fileName

fs = New IO.FileStream(filePath, IO.FileMode.Create)

fs.Write(b, 0, data.Length)

Catch ex As Exception

Me.ListBox1.Items.Add("Exception: " & ex.Message)

Finally

fs.Close()

End Try

Else

Me.ListBox1.Items.Add("No data recieved")

End If

End Sub


Nov 20 '05 #1
3 3501
Thomas,

You can use DataObject.GetDataPresent to test if FileContents is in the
DataObject.

HTH,

John Chen

Nov 20 '05 #2
Hi John,
the GetDataPresent returns true for the FileContents, but I can't get it
with the GetData, for some odd reason.
Any ideas?

Cheers,
Thomas
"John Chen" <jo******@microsoft.com> wrote in message
news:3#*************@cpmsftngxa06.phx.gbl...
Thomas,

You can use DataObject.GetDataPresent to test if FileContents is in the
DataObject.

HTH,

John Chen

Nov 20 '05 #3
How do you set the object into the DataObject?
Is your set object routine in the same project of the get object?
Is there any exceptions you see when you get the object?

John
Nov 20 '05 #4

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

Similar topics

11
by: kiran | last post by:
I am trying to implement a rubber band/image selection script. For that I need to remove the default drag behaviour on an image. I am able to do this in IE but not Netscape. Does any one have a...
1
by: kiran | last post by:
I am trying to implement a rubber band/image selection script. For that I need to remove the default drag behaviour on an image. I am able to do this in IE but not Netscape. Does any one have a...
3
by: NewSun | last post by:
How can i drag a datarow from a datagrid to a other control? e.g. Drag a datarow from a datagrid to a TextBox,Then display one colnumn' value of the datarow . Or Drag a cell's value to a controll...
1
by: Jon Cosby | last post by:
I need an event handler for dragging the cursor on a PictureBox. The existing events only include handlers for dragging and dropping objects over the controls. I'm trying to use the MouseDown and...
1
by: Chris | last post by:
Hi, I need to be able to detect when a drag is cancelled after it has started. Meaning: after the drag operation has begun, and the user does not complete the drag, but releases whatever's being...
2
by: Daniel | last post by:
Hello, in my application, i need to drag files from the windows explorer to the application, but also the other way round. To drag files from the explorer works fine (using...
0
by: Samuel R. Neff | last post by:
I have a typical TreeView/ListView combo and can drag from the ListView to the TreeView. I'd like to select the TreeView node that is the target of the drag operation as the ListView items are...
4
by: Peter | last post by:
Hi, Does anyone know how to drag a splitter by coding. I will put three controls on form1,two panels and a splitter. The first panel's dock property is set to top, the splitter's dock is also...
0
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
Being you can drag webparts from zone to zone, is there a way to control drag speed while dragging/scrolling up the page? I have a list of webparts that may go beyond the page. If a user wants...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.