Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

string directory=house+"\\"+"CommLog"+date+"RTB"+(i+1);

FileArr[0]=Path.GetFileNameWithoutExtension(directory);

 

It only returns the name I already know(RTB1,RTB2,RTB3...). It does not return the names of the files in the folder.

 

Another topic:

 

How can I say "Get anything"? Ex:

"c:\\folder\\"Get anything"\\file".

C#
Posted

When you have the fully qualified path plus filename in a string you can split the string with "\" as the splitter and the select the last element.

 

pseudocode ahead


Dim longName as string
Dim shortName as string

Dim parts() as string

parts = split(longName, "\")
shortName = parts(UBound(parts))

.nerd
Posted

That is VB not C#. And I need something that will not return any file name in any folder I specify no matter what the folder is.

 

I think that can be done with Batch files like this:

c:\folder\..\folder\..

Actually, that probably won't work, but you should get my point.

C#
  • *Experts*
Posted

You want a function that doesn't return files? I really don't

understand what you're looking for. Perhaps you should tell us what

the program is that you are trying to make?

Posted
The program saves the documents as the names of the labels. That is why I need the names of the files and only the files (no extention) because I will use it to name the labels when the files are opened.
C#
  • *Experts*
Posted

OK, so use the 'GetFiles' method (as shown above) to get the files

into an array (this will include extensions). Then when you do need

the filename without extension:

Dim noExt, dummy As String

For Each dummy In TheListOfFilesArray
 noExt = dummy.Split(".")(0)
 'noExt contains the file w/o extension so do something with it here
Next

Posted

Had to jump though some hoops for this one!

 

FileArr=Directory.GetFiles(directory);

 

MessageBox.Show(FileArr);

string[]file=FileArr.Split('.');

int start=file.LastIndexOf("\\");

file=file.Substring(start+1);

MessageBox.Show(file);

 

Does anyone know the answer to the question posted in my other post above, about how I can say "any folder or file" in my code?

C#
Posted

Here is what I wrote:

 

And I need something that will not return any file name in any folder I specify no matter what the folder is.

 

I think that can be done with Batch files like this:

c:\folder\..\folder\..

Actually, that probably won't work, but you should get my point.

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...