|
Actually i got a situation i want to enplane it.
I have an exe file that when i give it any path by parameter it generate 5 files as out put. But problem is that in the same directory where the exe is located. How can i handle this situation to fore this exe to generate out put at the source location.
One answer is that copy my exe to the source location ant run it after running delete my exe.
But how can i do it Programmatically i have no idea.
I you have any solution or idea regarding to it plz froward to me.
Thanks for all reply in advance.
|
|
|
|
|
When saving the file, why not just give it the full path to where you want it to be.
So rather than giving it the file name "myfile.txt" give it the file name "c:\users\myaccount\documents\myfilename.txt"? (or where ever you want the file to be written).
|
|
|
|
|
I am giving full path to the target file i.e
"c:\doc\text.txt"
but the proble is that there is not any argument to tell the exe to where save the output files. Bydefalult it save files from where the exe is running.
I have no code of the exe it is third party exe i am only using it....
|
|
|
|
|
Hi,
you may want to use Environment.GetFolderPath to obtain part of the path
you are interested in.
Environment.GetFolderPath(SpecialFolder.ApplicationData)+@"myappname\"
is a typical way of doing this.
|
|
|
|
|
Three little methods that might help.
System.IO.File.Move(@"c:\SourcePath", @"c:\DestinationPath");
System.IO.File.Copy(@"c:\SourcePath", @"c:\DestinationPath");
System.IO.File.Delete(@"c:\FileToDelete");
It's probably better to generate the output files, them move them to the required location rather than copying and deleting the exe, but that's up to you really.
Simon
|
|
|
|
|
If you don't know the full path of a file, but know you can access the files System.IO.Path.GetFullPath();
If you want to know where just a System.IO.File.Create("newFile.txt"); will write the file you can use System.IO.Directory.GetCurrentDirectory(); but it's best to give the full path of where the .Create() should make the file...
|
|
|
|
|
I would like to implement something similiar to the depends utility.
thanks
|
|
|
|
|
|
But still... I have some assemblies that get loaded dynamically via Reflection.
|
|
|
|
|
Obviously, reflecting the assembly won't catch that. Inspecting and decompiling the IL would.
/ravi
|
|
|
|
|
Not in the case where the app gets the name of the required assembly from a database.
|
|
|
|
|
Or if the app uses a web service to look up the connection string before accessing the db. Of course, it has to first look up the .disco resource in order to find the web service.
It's lunch time and the air is heavy with the aroma of spicy chicken with rice. Mmm mm!
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: It's lunch time and the air is heavy with the aroma of spicy chicken with rice. Mmm mm!
I wonder if they anything like that near where I'll be at lunch time today... there's supposed to be a McDonald's, but now you have me thinking on a higher level.
|
|
|
|
|
How do I invoke a method from a dll written in .NET 2.0 from .NET 1.1?
|
|
|
|
|
|
Hello everyone,
Two questions,
1.
How foreach utilizes the IEnumerator interface and IEnumerable interface? Any there any docuements? I am interested in it.
2.
Pros and cons compared with using foreach and using simple index variable to iterate? Like,
for (int i = 0; i < abc.Count; i++)
{
}
thanks in advance,
George
|
|
|
|
|
Foreach basically just calls GetEnumerator() on your collection, and then repeatedly calls MoveNext() on the enumerator to move through the collection.
No real difference. If your interested in performance, try it and time it, I suspect it makes nears as no difference.
Only con I can think of is that you can't modify a collection (add/remove) while you are foreaching through it, but you could if you just looped with an index (Although I wouldn't recommend it, you'd most likely screw something up, and miscount with your index or something)
Personally, I use for each most of the time. I can't think of the last time I used a normal for loop to go through a collection.
Simon
|
|
|
|
|
for is useful if you want to delete an item from a collection.
|
|
|
|
|
Cool, Pete!
regards,
George
|
|
|
|
|
You're welcome. BTW - the issue I'm referring to here is that you can't delete an item in an enumerator. It really doesn't like it.
|
|
|
|
|
Correct, thanks Pete!
regards,
George
|
|
|
|
|
Thanks Simon,
Your answer is complete.
regards,
George
|
|
|
|
|
Yeah, what they said.
Plus, some times a method takes a parameter of type IEnumerable so foreach is about the only option open to you, contrasted with a method that takes an array and you can choose.
If you have the choice to use foreach , for , or while and all you are trying to do is find one item in the collection; then foreach is somewhat frowned upon.
|
|
|
|
|
PIEBALDconsult wrote: If you have the choice to use foreach, for, or while and all you are trying to do is find one item in the collection; then foreach is somewhat frowned upon.
Why?
Simon
|
|
|
|
|
Because you're not actually doing something with "each" item. It's a conceptual distinction.
|
|
|
|