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

Finding files in a directory that begin with string

I am working on a package in SSIS that needs to check a directory to see if any files that begin with a three character string (PDE) exist, and set the value of a variable accordingly to determine which path the package should follow next.

Here is the code I am using. I found it on a similar thread in this forum. The code runs without error but does not update the variable to 1 when a file exists. Any suggestions?

Expand|Select|Wrap|Line Numbers
  1.         Dim AllFiles() As String = System.IO.Directory.GetFiles("\\fcfpsvr1\share\medicare\bipimport\incomingfiles\", "*.txt")
  2.  
  3.         Dim I As Integer
  4.  
  5.         For I = 0 To AllFiles.Length - 1
  6.             If AllFiles(I).StartsWith("PDE") Then
  7.                 System.Diagnostics.Debug.WriteLine(AllFiles(I))
  8.                 Dts.Variables("SourceFileExists").Value = 1
  9.             End If
  10.         Next
Aug 3 '07 #1
2 1451
Ah, resolved the issue. The file pathway was included as part of the filename, changing the .StartsWith() to .Contains() solved the problem.

...
If AllFiles(I).StartsWith("PDE") Then
Aug 3 '07 #2
Killer42
8,435 Expert 8TB
Ah, resolved the issue. The file pathway was included as part of the filename, changing the .StartsWith() to .Contains() solved the problem.
I suspect you could also shortcut the process like so...
Expand|Select|Wrap|Line Numbers
  1. Dim AllFiles() As String = System.IO.Directory.GetFiles("\\fcfpsvr1\share\medicare\bipimport\incomingfiles\  ", "PDE*.txt")
Aug 4 '07 #3

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

Similar topics

2
by: 73blazer | last post by:
Hello, I'm writing some C++ code, and I need to be able to find the number of files in a given directory. Is it possible under AIX4.3.3 with C++ 3.6.4? I cannot seem to locate anything of this...
5
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from...
8
by: ThunderMusic | last post by:
Hi, I'm currently building a little web site for me and my friends where we would like to be able to post big files (10Mb to 250Mb approx.) Right now the ASP.Net UploadFile control can't do it as...
8
by: ThunderMusic | last post by:
Hi, I'm currently building a little web site for me and my friends where we would like to be able to post big files (10Mb to 250Mb approx.) Right now the ASP.Net UploadFile control can't do it as...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...
0
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...
0
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...

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.