|
Process.Start is going to work if your file is on the file system. I suspect if you embedd the file in your exe, you're going to need to write it to the file system ( which would use streams ) and then call process.start. I don't know of a way to start a process where you have the file bytes in memory, but they are not on the HDD.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
It won't be a problem for the file to be on the file system, but my concern is that i have to add an error message for example when the file is missing (the user might have moved it). That's why i am trying to make it run from within the exe. If i have to create it on the file system wouldn't this slow a bit the program? I think if there is a way to load for example an embedded image or string, why shouldn't the be a way to load another file??? So far i can't seem to find a simple solution to the problem.
|
|
|
|
|
You can have a file on the system entry and if the file is missing then create it on the file system.
|
|
|
|
|
That is a good solution. I will try it. Thanks
|
|
|
|
|
You are welcome
|
|
|
|
|
Now it works nice!
<br />
string path = Application.StartupPath + "\\Graph Draw Help.chm";<br />
if (!File.Exists(path))<br />
{<br />
using (FileStream writeStream = new FileStream(path, FileMode.Create))<br />
{<br />
writeStream.Write(CodeResource.Graph_Draw_Help, 0,CodeResource.Graph_Draw_Help.Length);<br />
}<br />
}<br />
}
|
|
|
|
|
Glad to help you
|
|
|
|
|
Hi All,
Your going to get sick of me soon!
I need to pass around an instance of SingleDirectoyFileStore using some recursion. I've tried the ref keyword and even adding the List<FileEntry> as the identifier but none of them work.
public static object ScanDirectories(string scanEntryPoint)
{
List<FileEntry> SingleDirectoryFileStore = new List<FileEntry>();
DirectoryInfo StartDir = new DirectoryInfo(scanEntryPoint);
GetDirectoryFiles(StartDir);
return SingleDirectoryFileStore;
}
kicks off:
static void GetDirectoryFiles(DirectoryInfo filesInDirectory)
{
FileInfo[] files;
files = filesInDirectory.GetFiles("*.*");
foreach(FileInfo file in files)
{
string fileName = file.FullName;
string fileSize = file.Length.ToString(CultureInfo.InvariantCulture);
string fileExt = file.Extension;
string fileCreated = file.LastWriteTime.ToString(CultureInfo.CurrentCulture);
SingleDirectoryFileStore.Add(new FileEntry(fileName, fileSize, fileExt, fileCreated));
}
DirectoryInfo [] directorySubDirectory = filesInDirectory.GetDirectories("*.*");
foreach (DirectoryInfo dir in directorySubDirectory)
{
GetDirectoryFiles(dir);
}
}
Am I even going about this the right way?
TIA,
|
|
|
|
|
Jammer wrote: Your going to get sick of me soon!
No, you're asking clear questions, posting code, and asking in the right place. I say bring it on !!!
Jammer wrote: public static object ScanDirectories(string scanEntryPoint)
Why are you returning object and not List<FileEntry> ?
Jammer wrote: SingleDirectoryFileStore.Add(new FileEntry(fileName, fileSize, fileExt, fileCreated));
I think I answered this once before. You're creating the list as a local variable. You need to either pass it into GetDirectoryFiles ( so it exists there, it will be passed by reference ), or you need to make it a member variable. You say you've tried to pass it in, why did that not work ? What error did you get ? As the method is static, adding it as a static member variable seems like it would be harmless, just clear it at the top of ScanDirectories. Then you could also cache the result, if the same scanEntryPoint is passed in a second time, you could pass back the result without scanning again, if that was appropriate ( this would mean adding a static string to store the last scanEntryPoint )
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: No, you're asking clear questions, posting code, and asking in the right place. I say bring it on !!!
GREAT! I am trying to be as structured about this as possible as any ambiguity in questions can just add to the confusion ... something I really don't need at the moment!
Christian Graus wrote: Why are you returning object and not List<fileentry> ?
Noted ... I simply thought that as it was an object, the object keyword was the way to go with that ... I'll amend that in the code. I actually got this working just a moment ago by just adding to this line thus:
static void GetDirectoryFiles(List<FileEntry> SingleDirectoryFileStore, DirectoryInfo filesInDirectory)
I made the mistake originally by adding it again to this line:
foreach (DirectoryInfo dir in directorySubDirectory)
{
GetDirectoryFiles(SingleDirectoryFileStore, dir);
}
But of course ... its passing it back into the original code that is already aware of what SingleDirectoryFileStore is ...
I'm REALLY interested in the other point you make about storing the last scan directory and cacheing the results. Also how would I go about making the List<FileEntry> a member variable? I'm not even sure what a member variable is!
|
|
|
|
|
Jammer wrote: Noted ... I simply thought that as it was an object, the object keyword was the way to go with that
object has four methods = toString, GetHasCode, and two others that escape me. You will need to cast it back to the right object to use anything else. And, your code can now return anything, it's not at all clear what it returns. So, no, always strongly type stuff ( that is, make clear exactly what you're taking or returning ). Use object to say 'I will take anything and try to find a use for it'.
If I have a class, like this":
class MyClass
{
private int _myMemberInt;
public void Method()
{
int myLocalInt;
}
}
So, myLocalInt is only visible inside Method, but _myMemberInt is visible to any method in the class instance.
In your instance, it would be private static List etc ( that is, it would be static, so static methods can see it ). You'd call new on it in a static constructor, or inline ( that is, when you declare it ). Then when you call your method, you would call Clear to clear the old data.
Then, you can have a string property that stores the last search made. Now, if the search that comes in, is the same value, then your list already contains the result of that search, so you could just return that list, without doing the search again.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Brilliant! Its going to take me a while to ingest that but it sounds like the way forward.
One thing I'm noticing is that there are an awful lot of very badly written code examples out there in the wilds of the wibbly wobbly web. Some that purport to be 'a simple introduction to' are absolutely nothing of the sort. They assume you already know quite a lot about the ins and outs of the language.
You in particular have laid a few things out for me that are full of content and relative easy to grasp. Thanks for that!!
I'm having a few problems with my xamDataGrid binding to the List I'm generating now but I'm going to bang on with that for a moment, I have the WPF Unleashed book here that I hope will have some good things to say.
I was looking at your article on controlling the dimentions of grid panels the other day as I have to implement an accordian control over the next couple of weeks ... should be fun!
Best,
James.
|
|
|
|
|
Jammer wrote: One thing I'm noticing is that there are an awful lot of very badly written code examples out there in the wilds of the wibbly wobbly web.
Hell, yes. And some of the MSDN samples are right up there.
Jammer wrote: Thanks for that!!
*blush* glad to help
Jammer wrote: I have the WPF Unleashed book here that I hope will have some good things to say.
That is a good book.
Jammer wrote: I was looking at your article on controlling the dimentions of grid panels the other day as I have to implement an accordian control over the next couple of weeks ... should be fun!
The one with Nish ? We had a whole series planned, when time permits. Maybe soon....
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
I developing a security application that suppose to run before explorer.exe runs or perhaps before the start bar comes up and any other applications that the user may install...
So my question is how can I do it?
Maybe a registry value?
Thank you very much,
Yasa
|
|
|
|
|
I know the gina.dll is what handles the login. I suspect Explorer is the first thing that runs when a user has logged in.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: gina.dll is what handles the login
Huh... sounds like my wife.
|
|
|
|
|
|
I have a Windows Form ContextMenuStrip that I use with several controls on my form. The menu items themselves are instances of ToolStripMenuItem. I handle the Click event for each ToolStripMenuItem.
My problem is that inside the Click event, the sender is the ToolStripMenuItem, and I seemingly have no way of telling which control was originally right-clicked. I know which menu item was right-clicked, but I don't know the original control that was right-clicked.
I hate to create separate instances of ContextMenuStrip, since it is the same menu for all the controls I am working with.
How do I "pass-along" the a reference to the original control to the ToolStripMenuItem?
Thanks,
Mark
|
|
|
|
|
Use the SourceControl property of the ContextMenuStrip .
Eslam Afifi
|
|
|
|
|
I have a C# form that I want to act as a semi-transparent on-screen display. If the user clicks in my application I would like the message to be passed down to the window below it.
From Google, I've tried adding the GWL_EXSTYLE, WS_EXSTYLE and WS_EX_TRANSPARENT styles to the window with no luck.
I've also tried to override my WnnProc handler to return the MA_NOACTIVATE style to disregard the message and hopefully pass it on through:
<br />
protected override void WndProc(ref Message m)<br />
{<br />
if (m.Msg == WM_MOUSEACTIVATE)<br />
{<br />
m.Result = (IntPtr)MA_NOACTIVATE;<br />
}<br />
else <br />
base.WndProc(ref m);<br />
}
Neither worked. Does anybody have any suggestions on what to try?
Thanks,
Aaron
modified 12-Jul-20 21:01pm.
|
|
|
|
|
|
I didn't use the right terms appearently.
For those who are looking for a solution, override the CreateParams of the form:
<br />
protected override CreateParams CreateParams<br />
{<br />
get<br />
{<br />
CreateParams cp = base.CreateParams;<br />
cp.ExStyle |= WS_EX_TRANSPARENT;<br />
return cp;<br />
} <br />
}
modified 12-Jul-20 21:01pm.
|
|
|
|
|
iam working with listview on that listview, iam getting images. Now i need to enlarge that images how to do that please help urgent
|
|
|
|
|
Hi use this
<br />
this.listView1.View = System.Windows.Forms.View.LargeIcon <br />
<br />
Yogesh Agarwal
|
|
|
|
|
great subject.
urgent, did you say urgent? I'll put it at the bottom of my inbox then.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|