Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

.net how do I ask what a string starts with? 2

Status
Not open for further replies.

SteveJJH

Mechanical
Feb 5, 2009
109
Sorry if this is in the wrong forum for this question
I am writing a macro to save a SolidWorks drawing as a PDF and add some information to the filename at the same time.
I also would like it to save the file in a specific folder on the system dependant on the start of the filename.
I have the file name as a string, but I want to be able to write something along the lines of:
If the filename starts with “V”, put it in this folder, else if it starts with “MD”, put it in this folder, and so on, ignoring any subsequent characters in the filename.
I hope I’ve given enough information to be clear, any ideas anyone?
 
Replies continue below

Recommended for you

I forgot to mention, I also need it to take the first three digits and add it to a string, so for instance if the filename is V12345, I need it to go into a folder on the system called V12000. So I will probably need a variable that is just the first 3 characters of the filename
 
because I have no idea what that means. I should have mentioned I'm no pro when it comes to code
 
Google regular expressions and .net. You might search eng-tips or tech-tips. There are a lot of programmers and programming fora.

Anytime you have to search a string regular expressions are the way to go. They are also known as regex. They have been implemented in Windows programming languages for years.

TOP
CSWP, BSSE
Phenom IIx6 1100T = 8GB = FX1400 = XP64SP2 = SW2009SP3
"Node news is good news."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor