473,796 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy folder problem

I am working on problem of coping folder.

I am using Windows XP/VB.Net 2003

I know how to do it with FileSystemObjec t, but I would like to have copy
dialog between operation like it is in windows explorer.
Is it possible to do this with System.IO (framework)?

I tried to use SHFileOperation (SHFileOP), but something is wrong.

After setting SHFileOp structure like

With SHFileOp
.wFunc = FO_COPY
.pFrom = "C:\Temp" & Chr(0) & Chr(0)
.pTo = "C:\Backup" & Chr(0) & Chr(0)
.fFlags = FOF_SIMPLEPROGR ESS
End With

my program stop with:

An unhandled exception of type 'System.NullRef erenceException ' occurred in
xxx.exe
Additional information: Object reference not set to an instance of an
object.

I don't know where is the problem.

Thanks all for help!!!

Simon
Nov 20 '05 #1
3 2249
Hi,

API Declare
<DllImport("she ll32.dll", entrypoint:="SH FileOperationA" , _

setlasterror:=T rue, CharSet:=CharSe t.Auto, exactspelling:= True, _

CallingConventi on:=CallingConv ention.StdCall) > _

Public Shared Function SHFileOperation (ByRef lpFileOp As SHFILEOPSTRUCT) As
Integer

End Function

Structure

Structure SHFILEOPSTRUCT

Dim hwnd As Integer

Dim wFunc As Integer

Dim pFrom As String

Dim pTo As String

Dim fFlags As Short

Dim fAnyOperationsA borted As Integer

Dim hNameMappings As Integer

Dim lpszProgressTit le As String ' only used if FOF_SIMPLEPROGR ESS

End Structure

How To Use

Const FO_COPY = &H2

Const FOF_SIMPLEPROGR ESS = &H100 ' means don't show names of files

Dim foCopy As SHFILEOPSTRUCT

With foCopy

.wFunc = FO_COPY

.pFrom = "C:\Temp" & Chr(0) & Chr(0)

.pTo = "C:\Backup" & Chr(0) & Chr(0)

.fFlags = FOF_SIMPLEPROGR ESS

End With

SHFileOperation (foCopy)

Ken

------------------

"Simon Abolnar" <Si***********@ tscng.net> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am working on problem of coping folder.

I am using Windows XP/VB.Net 2003

I know how to do it with FileSystemObjec t, but I would like to have copy
dialog between operation like it is in windows explorer.
Is it possible to do this with System.IO (framework)?

I tried to use SHFileOperation (SHFileOP), but something is wrong.

After setting SHFileOp structure like

With SHFileOp
.wFunc = FO_COPY
.pFrom = "C:\Temp" & Chr(0) & Chr(0)
.pTo = "C:\Backup" & Chr(0) & Chr(0)
.fFlags = FOF_SIMPLEPROGR ESS
End With

my program stop with:

An unhandled exception of type 'System.NullRef erenceException ' occurred in
xxx.exe
Additional information: Object reference not set to an instance of an
object.

I don't know where is the problem.

Thanks all for help!!!

Simon

Nov 20 '05 #2
* "Simon Abolnar" <Si***********@ tscng.net> scripsit:
I know how to do it with FileSystemObjec t, but I would like to have copy
dialog between operation like it is in windows explorer.
Is it possible to do this with System.IO (framework)?
No, that's not included in the .NET Framework.
I tried to use SHFileOperation (SHFileOP), but something is wrong.


Implementation in C#:

<http://www.codeproject .com/csharp/csdoesshell2.as p>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Cor
Hi Simon,

Did you look at the clipboard function for files?

Cor
Nov 20 '05 #4

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

Similar topics

8
17039
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts with '\\' it doesnt work and exception is thrown (for example: \\MyComputer\DestDirectory). Even if the first and the second directories are actually the same- the File.Copy() doesn't work. Is there any way to copy a file to a different computer?...
3
2192
by: Johnny | last post by:
Hi, I have created an ASP.NET application (let's call it FooBar) with VS.NET on my local machine, residing in http://localhost/FooBar. Deploying it to another folder on my machine works well with FrontPage Server Extensions, but I don't manage to deploy the application to my web provider http root folder. When I run Copy Project, I get an error message just saying 'Unable to create Web project 'myname'. Not found.'.
4
11741
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new file or changes (to files or folders) then it copies the files (and any new folders) to a folder in the mapped network drive. So far I have been successful in developing and deploying the service which works on my local machine with two drives...
5
3265
by: Saabster | last post by:
Hi all, It's always the simple stuff that trips you up I guess. Here is the issue I'm dealing with. I have a folder with 1400 excel files that I need to move to another location. Since each file has to go in to a particular target folder I decided that writing a program to move the files is they way to go. I've got all but this last piece down. and for the life of me I can't
25
2899
by: Andy_Khosravi | last post by:
I just recently changed my database that I'm running from a monolithic DB to a split FE/BE. The front end resides on the client machine and the BE resides on a network drive. I'm experimenting with a utility developed by Tony Toews to handle the distribution and subsequent updates of the software. I'm having some trouble with the overall upgrade process I've implemented, and I'm hoping one of you may have an idea how to go about fixing...
4
4738
by: maheswaran | last post by:
Hi, I copy the file from local to server using "Copy" function. see Copy($localfile,"Document/01/$file) The number 01 is incresing dynamically according to number of files in a folder. If folder "01" have 9 files than new local files is copied in to directory 10. The directory 10 is created while use the copy function Copy($localfile,"Document/01/$file")
3
5151
by: =?Utf-8?B?R2FuZXNoYQ==?= | last post by:
Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to a shared folder. eg., File.Copy(srcPath, "\\machinename\\folder) This is giving an error "Could not find part of the path \\machinename\\folder" Is this feature supported? if yes please can anyone let me knwo how to
2
1786
by: swethak | last post by:
hi, i want to copy the contents of one folder into another folder.For that i create the one new folder . I copied the files of already existing folder into new folder.For that i write a code as <?php mkdir("filesscreate",0777); copy('admin','filescreate'); ?>
9
6503
by: AWW | last post by:
Running XP - Visual Studio 2005 - VB Want to have duplicate projects - one safe and stable - other for experimenting Can't fine easy way to make duplicate project. Stupid question? or stupid ME? Thanks.
10
4965
by: Jason | last post by:
I want to create a simple program with Two buttons on the form. BUTTON 1 - BACKUP PREFS this will do the following: Copy C:\Documents and Settings\%USERNAME%\Application Data\FileZilla \sitemanager.xml to this location: \\drake\pvt\%USERNAME%\FileZilla-Prefs\ BUTTON 2 - RESTORE PREFS this will do the opposite:
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.