Hiya guys, have read in a file name but its in a weird format, like
this
filename.date.key
i need to trim off .key any ideas? TrimEnd is not filling me with joy.
Cheers
Laura 5 2216
Laura,
Did you ever had a look at the path class, seems exactly made for your
question. http://msdn.microsoft.com/library/de...classtopic.asp
Cor
"laurasaur" <la*******@gmail.comschreef in bericht
news:11*********************@y80g2000hsf.googlegro ups.com...
Hiya guys, have read in a file name but its in a weird format, like
this
filename.date.key
i need to trim off .key any ideas? TrimEnd is not filling me with joy.
Cheers
Laura
laurasaur <la*******@gmail.comwrote:
Hiya guys, have read in a file name but its in a weird format, like
this
filename.date.key
i need to trim off .key any ideas? TrimEnd is not filling me with joy.
if (filename.EndsWith(".key"))
{
filename = filename.Substring (0, filename.Length-4);
}
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
On Apr 2, 3:07 pm, "Cor Ligthert [MVP]" <notmyfirstn...@planet.nl>
wrote:
Laura,
Did you ever had a look at the path class, seems exactly made for your
question.
http://msdn.microsoft.com/library/de...ary/en-us/cpre...
Cor
The get extension methods of the path class dont work in my situation,
as the filename has many periods in it, ie
filename.date.time.key
so getextension doesnt work in this situation as far as I can tell :)
On Apr 3, 6:36 am, Jon Skeet [C# MVP] <s...@pobox.comwrote:
>
if (filename.EndsWith(".key"))
{
filename = filename.Substring (0, filename.Length-4);
}
I did something similar in the end,
//string name = the file name string
int position = name.LastIndexOf('.');
string Sendbak = name.Remove(position);
As I already know that the file will always have a .key extension.
Thanks for all your help everyone
laurasaur <la*******@gmail.comwrote:
I did something similar in the end,
//string name = the file name string
int position = name.LastIndexOf('.');
string Sendbak = name.Remove(position);
As I already know that the file will always have a .key extension.
Thanks for all your help everyone
If you already know it will already have a .key extension, you can just
use:
string Sendbak = name.Remove(name.Length-4);
Somehow I'd managed to miss the addition of the "Remove" method in 2.0
:)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon |
last post by:
Hi,
I have written a function to trim char *, but I have been told that my way
could be dangerous and that I should use memmove(...) instead.
but I am not sure why my code could be 'dangerous'...
|
by: Darren Anderson |
last post by:
I have a function that I've tried using in an if then statement and I've
found that no matter how much reworking I do with the code, the expected
result is incorrect.
the code:
If Not...
|
by: Sascha Herpers |
last post by:
Hi,
what is the difference between the trim function and the trim
String-member?
As far as I see it, both return the trimmed string and leave the
original string unaltered.
Is any of the two...
|
by: Jonathan Wood |
last post by:
According to the intellisense help, string.Trim() "Removes all occurances or
white space characters from the beginning and end of this instance."
However, the follow code does not appear to...
|
by: Terry Olsen |
last post by:
I have an app that makes decisions based on string content. I need to make
sure that a string does not contain only spaces or newlines. I am using the
syntax 'Trim(String)" and it works fine. I...
|
by: Pascal |
last post by:
bonjour hello
I would like to trim a string of all its white spaces so i used
myString.trim() but it doesn't work as supposed : unsecable space are
remaining in the middle of my string...
i...
|
by: rkk |
last post by:
Hi,
I've written a small trim function to trim away the whitespaces in a
given string. It works well with solaris forte cc compiler, but on
mingw/cygwin gcc it isn't. Here is the code:
char...
|
by: Oleg Subachev |
last post by:
If I apply Trim() method to string consisting of two x0D and x0A characters
the resulting string is not empty but contain the same two charaters: x0D,
x0A.
But according to the help Trim()...
|
by: Kevin Smith |
last post by:
Hi,
According to the intellisense help, string.Trim() "Removes all occurances
or white space characters from the beginning and end of this instance."
However, the follow code does not appear...
|
by: Keith Thompson |
last post by:
Kevin Smith <no@spam.comwrites:
You posted this to microsoft.public.dotnet.languages.csharp, where I
presume it's topical. Why on Earth did you redirect followups to
comp.lang.c?
Anyone...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |