
Signature
ats@jbex
No mercy for what we are doing
No thought to even what we have done
We don't need to feel the sorrow
No remorse for the helpless one
Metallica - No Remorse
Ats,
Use DirectoryInfo.GetFiles, rather than Directory to get an array of
FileInfo objects, as the code below demonstrates.
Hope that helps.
Ralph Shillington
iFoundTIme Inc
http://www.ifoundtime.com/community
home of the coffee break tutorials.
Imports System.IO
Module Module1
Sub Main()
Dim files() As FileInfo = New DirectoryInfo("c:
\").GetFiles("*.txt")
For Each file As FileInfo In files
Console.WriteLine(file.FullName)
Next
End Sub
End Module
On Apr 17, 4:49 am, "ats@jbex" <a...@allenjones.NOSPAM.co.PLEASE.uk>
wrote:
> I am working on a program that will look in a folder and if it finds a
> particular file type (i.e. a .TRN or a .BAK file), it will move the file to
[quoted text clipped - 13 lines]
>
> Metallica - No Remorse
ats@jbex - 17 Apr 2007 12:43 GMT
Thanks for that, it does the trick. The problem I now have is that my
program creates a directory using the Directory.CreateDirectory(FullPath)
call. The directory is created but when I try to move a file into it I get
an error saying that I do not have permission to access the folder. If I
view the folder in Windows Explorer I can open it and move files into it.
Any ideas?
TIA
> Ats,
> Use DirectoryInfo.GetFiles, rather than Directory to get an array of
[quoted text clipped - 39 lines]
>>
>> Metallica - No Remorse

Signature
ats@jbex
But I learned to burn that bridge and delete
Those who compete...at a level that's obsolete
Instead I warm my hands upon the flames of the flag
As I recall our downfall
And the business that burned us all
See through the news and the views that twist reality
Rage Against The Machine - Bombtrack
rshillington - 18 Apr 2007 14:46 GMT
hmmm --- Do you perhaps have the file open that you're trying to
move? Could you post a snippet of the code the reproduces the
problem? How you create the directory shouldn't matter.
Ralph Shillington
iFoundTIme Inc
http://www.ifoundtime.com/community
home of the coffee break tutorials.
On Apr 17, 7:43 am, "ats@jbex" <a...@allenjones.NOSPAM.co.PLEASE.uk>
wrote:
> Thanks for that, it does the trick. The problem I now have is that my
> program creates a directory using the Directory.CreateDirectory(FullPath)
[quoted text clipped - 62 lines]
>
> - Show quoted text -
ats@jbex - 18 Apr 2007 15:08 GMT
Hi there,
Thanks for the reply. The file is definitely not open when I try to move
it. The code I use is here:
Sub MoveData()
Dim f As String = ""
Dim d As Date = DateAdd(DateInterval.Day, -1, Date.Today)
Me.Label1.Text = "Creating Directory"
f = "F:\DataBackup" & Format(d, "yyyymmdd")
Directory.CreateDirectory(f)
Me.Label1.Text = "Moving Backup Transaction Logs"
Dim filesTRN() As FileInfo = New
DirectoryInfo("G:\").GetFiles("*.TRN")
For Each file As FileInfo In filesTRN
file.MoveTo(f)
Next
Me.Label1.Text = "Moving Backup DB Files"
Dim filesBAK() As FileInfo = New
DirectoryInfo("G:\").GetFiles("*.BAK")
For Each file As FileInfo In filesBAK
file.MoveTo(f)
Next
End Sub
Thanks again.
> hmmm --- Do you perhaps have the file open that you're trying to
> move? Could you post a snippet of the code the reproduces the
[quoted text clipped - 4 lines]
> http://www.ifoundtime.com/community
> home of the coffee break tutorials.

Signature
ats@jbex
The world is my expense
The cost of my desire
Jesus blessed me with its future
And I protect it with fire
Rage Against The Machine - Sleep Now In The Fire