473,830 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileInfo.CopyTo Problem

Hi,
I have a Windows VB.Net app in which I need to keep files in one folder in sync with files in another folder. I have pasted the code below. Can anyone tell me why I end up with a folder with all the file names correct, but the length of each file is zero.
Thanks for your help.
Michael

Public Function SyncFiles() As Integer
Dim CopyToPath As String
Dim CopyFromPath As String
Dim CopyToPathFileI nfo As FileInfo
Dim CopyFromPathFil eInfo As FileInfo

Try
CopyAllFiles = False
For i As Integer = 0 To intNumberOfSlot s - 1
CopyFromPath = AdSlotRecords(i ).strPathAndFil enameOfAdClip
CopyFromPathFil eInfo = New FileInfo(CopyFr omPath)
CopyToPath = AdSlotRecords(i ).strPathAndFil enameOfAdClipOn Client
CopyToPathFileI nfo = New FileInfo(CopyTo Path)
If CopyFromPathFil eInfo.Exists Then ' Make sure source exists
If CopyToPathFileI nfo.Exists Then ' If target exists check for latest version
If CopyFromPathFil eInfo.LastWrite Time > CopyToPathFileI nfo.LastWriteTi me Then
CopyFromPathFil eInfo.CopyTo(Co pyToPath, True)
End If
Else
CopyFromPathFil eInfo.CopyTo(Co pyToPath, True)
End If
Else
Return False
End If
Next
Return True
Catch ex As Exception
Return False
End Try
End Function

--
Michael D. Murphy
Senior Software Architect
SCS-TechResources, Inc.
1400 NW 70 Way
Suite HO1
Plantation, FL 33313-5330
md******@scs-techresources.c om
954-452-1047

Nov 21 '05
10 5901
Hi Peter,
Yes and thanks for your feedback.
Because I wants to duplicate Michael's problem, so I try to make change to
Michael's code as small as possible.


But why do you sent that too a message that ends with this.
Hi Cor,
.
.
. I copied the original files back to
where they were supposed to be and it all works great.
Thanks for your help.
Michael


It makes the thread not more readable on Google, however I think you missed
that and no problem.

:-)

Cor
Nov 21 '05 #11

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

Similar topics

3
7579
by: Stefan Turalski \(stic\) | last post by:
Hi, I used to use CopyTo() method from FileInfo class, does anyone know if there is a way to bind this with progressbar, or with some sort of paintBox - to show progress of moving/coping file ? -- best regards Stic
1
597
by: Mortimer Schnurd | last post by:
Has anyone had any luck getting this CopyTo method to work? I can iterate through a MatchCollection and move each Match.Value to the System.Array without a problem. I just can't figure out why the CopyTo method will not work. Example: // Find all the Tables in an html string (page) MatchCollection mc = Regex.Matches(html, "<table.+</table"); string t = new string;
3
3618
by: | last post by:
I have a collectiond derived from NameObjectCollectionBase. FxCop is complaining that I need to implement a strongly typed CopyTo(MyObjectType, int) How do I do this? I can't seem to find any implementations of CopyTo() that don't rely on Array.Copy or some other internal .NET method. Unfortunately, there's nothing I can find that will work for a NameObjectCollectionBase derived class. I can't find any implementations of CopyTo() for...
3
2539
by: pengbsam | last post by:
Hello All: Having a problem with arraylist.copyto function. And here's a sample of my code in C#: In global--> public struct point { int x; string y; }
2
3588
by: pengbsam | last post by:
Hello All: Having a problem with arraylist.copyto function. And here's a sample of my code: In global--> public struct point { int x; string y; } static public point point;
6
3028
by: KWienhold | last post by:
I'm currently working on a project in C# (VS 2003 SP1, .Net 1.1) that utilizes IStream/IStorage COM-Elements. Up to now I have gotten everything to work to my satisfaction, but now I have come across a problem I can't really explain: When deleting an object from an IStorage, the space it used up will not be freed, but rather marked as unused and overwritten the next time you add an object to the storage. This is obviously working as...
1
2056
by: schmidtfalko | last post by:
Hi, i use the CopyTo - Function to copy large files into a net drive. Now it would be mad, if I could indicate the remaining time or also the status (in %) to the copying action. Have unfortunately still nothing found... Is there a possibility?
0
2694
by: dolphinearth | last post by:
Hi. I have a strange problem around DirectoryInfo and FileInfo of C# (c- sharp). I have a File Watcher which automattically imports files from a network drive to a directory on the local machine. Here is the code I used: DirectoryInfo dir = new DirectoryInfo(SAPImportPath); FileInfo fileList = dir.GetFiles("*.txt");
2
2129
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
In VB I use FileInfo.CopyTo and get an error when the destination file already exists. What do I use to copy to a destination and write over the existing file? Thanks, Jon
0
9780
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
10769
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10476
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
10196
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
9310
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...
1
7739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6940
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
5775
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4408
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

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.