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

drag and drop office 2007 visual c#

hallo everyone,

Actually i know how to drag and drop text file into WPF and read it but i need to drag and drop office 2007 file and extract the file and the xml file in it.

This is the code i have to drag and drop and read a text file.

Expand|Select|Wrap|Line Numbers
  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3.     this.AllowDrop = true;
  4.     this.DragEnter += Form1_DragEnter;
  5.     this.DragDrop += Form1_DragDrop;
  6. }
  7. private void Form1_DragEnter(object sender, DragEventArgs e)
  8. {
  9.     if (e.Data.GetDataPresent(DataFormats.FileDrop))
  10.     {
  11.         e.Effect = DragDropEffects.Copy;
  12.     }
  13.     else
  14.     {
  15.         e.Effect = DragDropEffects.None;
  16.     }
  17. }
  18.  
  19. private void Form1_DragDrop(object sender, DragEventArgs e)
  20. {
  21.     if (e.Data.GetDataPresent(DataFormats.FileDrop))
  22.     {
  23.         string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
  24.         foreach (string fileLoc in filePaths)
  25.         {
  26.             // Code to read the contents of the text file
  27.             if (File.Exists(fileLoc))
  28.             {
  29.                 using (TextReader tr = new StreamReader(fileLoc))
  30.                 {
  31.                     MessageBox.Show(tr.ReadToEnd());
  32.                 }
  33.             }
  34.  
  35.         }
  36.     }
  37. }
  38.  
I also have the code to unpack the office file and read the xml file.
Expand|Select|Wrap|Line Numbers
  1. Package pack = Package.Open(strFilename, FileMode.Open, FileAccess.ReadWrite);
  2. Uri uri = new Uri("/docProps/cwe-context.xml", UriKind.Relative);
  3. PackagePart packPart = pack.GetPart(uri);
  4. XmlDataDocument xdoc = new XmlDataDocument();
  5. xdoc.Load(packPart.GetStream(FileMode.Open));
  6. XmlNodeList doc = xdoc.GetElementsByTagName("sioc:Item");
  7.  
  8.  
.

any idea ?..


Thank you.
Feb 4 '09 #1
3 1907
Curtis Rutland
3,256 Expert 2GB
Well, if you know the code to accept a dropped file, and you know the code to read the XML from an office file...what more do you need? Just use them together.
Feb 4 '09 #2
hi insertalias,

Actually i can accept the txt file and i could read it but when i drop the office file in it, i couldn't upack it and read the xml file in it with the code i have. So is there any mistake in my code or i have change something else ?..

Thank you.
Feb 5 '09 #3
@insertAlias
hi insertalias,

Actually i can accept the txt file and i could read it but when i drop the office file in it, i couldn't upack it and read the xml file in it with the code i have. So is there any mistake in my code or i have change something else ?..

Thank you.
Feb 5 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JS | last post by:
In vs 2003/1.1 runtime I was using the NetXP (www.dacris.com) extensions that allowed you to make windows forms that had the tab control found in Visual Studio .NET. I mean like the solution...
8
by: WindAndWaves | last post by:
Hi everyone, Has anyone got any experience with drop and drag in Access? I would like to make a calendar style form where my users can drop and drag appointments.... I am using Access 2003...
2
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application...
3
by: James Radke | last post by:
Hello, I was curious, is it possible to create drag and drop interface from listbox to listbox on a webform application (i.e. vb.net)? Basically the application would need to load multiple...
1
by: Darren | last post by:
I'm trying to create a file using drag and drop. I want to be able to select a listview item drag it to the shell and create a file. Each icon in the listview represents a blob in a database. When...
1
by: Nick | last post by:
Hi, I am developping an app using managed C++. I want to be able to do a drag drop from the app to windows explorer. The files to be dropped onto explorer do not exist yet, the files are to be...
1
by: Thi | last post by:
Hi, I am trying to develop an application that allows the users to drag a few file(s) from a zip archive to a destination. My question is, how do i determine where the drop destination is...
5
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with...
1
by: asharda | last post by:
Hi, I have a listbox on my WPF window and a cnavas. I have to be able to drag the items from the list box and drop them on the canvas and draw the item accorgingly. If anyone knows how to...
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.