Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

If  ...Filename  ...Then

Posted on 2004-04-02
7
Medium Priority
?
302 Views
Last Modified: 2011-09-20
Hi,

How can I send a file to a 'folderA' if its file name is 'file1', otherwise I send it to 'folderB' if its name is 'file2' ?

Thanks for your help
0
Comment
Question by:chspit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Expert Comment

by:ptakja
ID: 10744151
Could you be more specific?  How do determine the filename?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10744486
ASP.NET or Windows Form?

Bob
0
 

Author Comment

by:chspit
ID: 10744633
i have a FileSystemWatcher that watches a folder. If a file arrives at this specific folder i want the FileSystemWatcher to react by sending the arrived file to 'FolderA' if the file name is 'file1', or send the file to 'FolderB' if file name is 'file2', otherwise the file is deleted.

0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 15

Accepted Solution

by:
Timbo87 earned 500 total points
ID: 10744644
You could do something like this:

Imports System.IO

Dim fileName As String = "c:\file1.txt"
'Dim fileName As String = "c:\file2.txt"

If fileName = "c:\file1.txt" Then
  File.Move(fileName, "c:\folderA\file1.txt")
Else
  File.Move(fileName, "c:\folderB\file1.txt")
End If

You can comment the first fileName and uncomment the second fileName if you want to test it. These files and folders need to exist or the program will throw an exception.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10744659
Dog pile on the easy question!!!!! :)

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10744661
Something simple like this might help:

   Public Sub TransferFile(ByVal strFileName As String)

      Const FolderA As String = "Folder A"
      Const FolderB As String = "Folder B"

      If strFileName = "file1" Then
         System.IO.File.Copy(strFileName, FolderA)
      ElseIf strFileName = "file2" Then
         System.IO.File.Copy(strFileName, FolderB)
      Else
         System.IO.File.Delete(strFileName)
      End If

   End Sub

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10744738
Slip sliding away.........

Bob
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question