|
string strPath = @"D:\XML Tutorial(Basics).doc";
string strFileName = strPath.Substring(strPath.LastIndexOf("\\") + 1);
Here it works fine to separate the filename.
Apart from "LastIndexOf", Is there any method to split the filename from the path.
pls give the solution ASAP
|
|
|
|
|
Hi,
Use the following:
string filename=System.IO.Path.GetFileName("YourFilePath");
Naresh Patel
|
|
|
|
|
Hello,
to split a string, you would use the:
String.Split[^] method.
Dealing with filename and pathes you could use the fancy features of System.IO.Path[^] namespace!
In your case, the GetFileName[^] method will do what you need.
string strPath = @"D:\XML Tutorial(Basics).doc";
string strFileName = System.IO.Path.GetFileName(strPath ); /will return: 'XML Tutorial(Basics).doc'
Hope it helps!
All the best,
Martin
|
|
|
|
|
you can use System.IO.Path Class to do that
like
<br />
string path=@"C:\my Pics\test.bmp";<br />
string fileName=System.IO.Path.GetFileName(path);
good luck
|
|
|
|
|
Hi,
I am C# programer, I have to test one server side application which is written in VB by making a client application in C#, that how much load it can bear, i would like if anybody provide me code for testing this senario.
I have to load as much as 100 user at same time login (instantly).
Thanks in advanced.
Amit
|
|
|
|
|
HI Amit,
Well u can test out your application by using LoadRunner application load test tool. Its a classic tool to generate an environment which will help u to carry out stress test of your application. Please download the 10 Days trial version from the site for "Mercury Loadrunner". U can even search out for simpler tools which are available on net for free.
Thanks
Amit kadam
Amit Kadam
|
|
|
|
|
is there any method to delete an object in c# explicitly or i have to set obeject to null and then wait for GC to delete it.v
skhurram
|
|
|
|
|
Use dispose method
obj.Dispose();
Thanks
|
|
|
|
|
There really is no 'Explicit' deletion of managed objects in .net like there are in other languages such as c++. You will have to always wait for th GC to do it stuff. obj.Dispose is just a clean up method really designed for releasing unmanged resources like handles.
The Dispose Pattern discusses disposing of objects
Keep your eyes open, you might spot alternatives.
|
|
|
|
|
There is no way to "delete" an object in .NET like you do in C or C++. The closest you can get is to call the Dispose method if it's available (or the appropriate equivalent since some classes have a Close method that actualy does the same work as Dispose ) and wait for the GC to delete it.
Check out this article Implementing IDisposable and the Dispose Pattern Properly[^] for more details on how to use Disopse .
|
|
|
|
|
Can anybody give me some idea on displaying a form from its right most position to left most.Just as reverse to its normal display.Here i want to use a timer while displaying the form.
|
|
|
|
|
you just go to the properties of the form and set the localize = true with the location 0,0 .
Assaf
|
|
|
|
|
Hi assaf,
Actually i didn't explained my question clearly.I have display a form from a specified pt lets say(x1+width,y1) to(x1,y1).
|
|
|
|
|
write the code in ur form
this.location = new point(x1+width,y1)
Is it solve ur issue?
Thanks
|
|
|
|
|
It is not correct solution to my issue.Otherwise is it possible to display a form in reverse co-ordinates interms of its width? Lets say it starting location is (x1,y1) and its end pt should be (x1-width,y1-height).
|
|
|
|
|
I am not clear abt ur issue.I think u want to reverse the form.If u put a control at position (0,10) when u reverse it should display at (width,10). Is it?
Can I know why u want to reverse the form?I think it is not possible..not sure.
Thanks
|
|
|
|
|
I will give a brief about my requirement i have to expand a child window form to the left or right side of the parent window depending on the parent window location when i click on a button. And there should be more button on the child form when clicked ,then that window should be collapsed.
Thanks for your assistance.
|
|
|
|
|
Now much clear I think.You can do this from your parent form.In parent (let assume form1)form's button (btnForm) click event call the form2
btnForm_Click()
**********************
form2 f = new form2()
f.size = new Size(100, 100); //set the size of ur form2
f.location= new point(this.Location.X + this.Width -100 , this.Location.Y ); // here 100 is width of form2
f.Show();
hope this will work for u ...
if not pls let me know.Thanks
-- modified at 4:51 Friday 17th August, 2007
|
|
|
|
|
I am sorry to say this is not exactly wat i am looking for.It can display the form2 on the right hand side of the form1.But my requirment is to expand the form2 from its extream right to its staring location with the help of a timer control.
Thanks
|
|
|
|
|
If i want to search for sentence in a whole string
how i can do?
Ex:
str ="SELECT Currency.CurrCode, Currency.CurrName FROM CurRate INNER JOIN Currency ON CurRate.Code = Currency.CurrCode"
I want to check if CurrCode exist or not ?
and how to check from the case sensitive
Thanks a lot
Assaf
|
|
|
|
|
There are few methods to case sensative searches
convert or cast the search field to varbinary
Decalre @Code varchar(50)
set @Code = 'A22'
SELECT Currency.CurrCode, Currency.CurrName FROM CurRate INNER JOIN Currency ON CurRate.Code = Currency.CurrCode where CAST(CurRate.Code as varbinary(50)) = CAST(@Code as varbinary(50))
points to note:- @Code type & size (here varchar(50) should be same as CurRate.Code
Hope this will solve your issue.
Thanks
|
|
|
|
|
Use the IndexOf method of the string class. There are overloads where you specify a StringComparison value that determines how the comparison is done.
---
single minded; short sighted; long gone;
|
|
|
|
|
// Trying to Save uploaded file to server using the file base name
FileUpload1.PostedFile.SaveAs(strPath + "\\" + strFilename);----This is my code
I get this error to the above code "Could not find the path to the file"
Any suggestions to fix my code??
|
|
|
|
|
Did you set a breakpoint on that line? Did you see what the path evaluates to? Did you check if it's valid?
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Well the FileUpload Control---used to Browse and select the file works.
Another Button adjacent to the FileUpload button is used to save the file selected by the Browse button inside the server and that does not work. My browse button code is:
private void FileUpload_Click(object sender, System.EventArgs e)
{
string strFilename;
{
// Get the file name
strFilename = FileUpload1.PostedFile.FileName;
// Exit if no file name was entered
if (strFilename == "") return;
}
}
|
|
|
|