Detecting the Path. Please help!
-
Hi! I have the following code: Stream stream = new FileStream("Form1.resx", FileMode.Open); And the default directory for Form1 is in WindowsApplication1\Bin\Debug right? But I want to use the resx in the WindowsApplication folder. How do I do this? Please help this newbie. :( "To teach is to learn twice"
-
Hi! I have the following code: Stream stream = new FileStream("Form1.resx", FileMode.Open); And the default directory for Form1 is in WindowsApplication1\Bin\Debug right? But I want to use the resx in the WindowsApplication folder. How do I do this? Please help this newbie. :( "To teach is to learn twice"
Form's .resx file is an embedded resource. This means you can access it as shown below:
Assembly assembly = Assembly.GetEntryAssembly();
Stream stream = assembly.GetManifestResourceStream(
"WindowsApplication1.Form1.resx");Alexandre Kojevnikov MCAD charter member Leuven, Belgium
-
Form's .resx file is an embedded resource. This means you can access it as shown below:
Assembly assembly = Assembly.GetEntryAssembly();
Stream stream = assembly.GetManifestResourceStream(
"WindowsApplication1.Form1.resx");Alexandre Kojevnikov MCAD charter member Leuven, Belgium
-
daljv wrote: What namespace will i add for this? Whichever you find appropriate. Just don't forget to update the parameter of
GetManifestResourceStream()
to"Namespace.Of.Form1.resx"
. Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
I probably misunderstood your question. You will need:
System.Reflection
andSystem.IO
. Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
daljv wrote: What namespace will i add for this? Whichever you find appropriate. Just don't forget to update the parameter of
GetManifestResourceStream()
to"Namespace.Of.Form1.resx"
. Alexandre Kojevnikov MCAD charter member Leuven, BelgiumHi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"
-
I probably misunderstood your question. You will need:
System.Reflection
andSystem.IO
. Alexandre Kojevnikov MCAD charter member Leuven, BelgiumHi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"
-
Hi! I used the follwing code: Assembly assembly = Assembly.GetEntryAssembly(); Stream stream = assembly.GetManifestResourceStream("WindowsApplication7.Form1.resx"); ResourceReader a = new ResourceReader(stream); IDictionaryEnumerator en = a.GetEnumerator(); en.MoveNext(); MessageBox.Show(en.Key.ToString()); MessageBox.Show(en.Value.ToString()); a.Close(); But I get an exception stating that: An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Additional information: Value cannot be null. Why is this? "To teach is to learn twice"
Replace
WindowsApplication7.Form1.resx
withWindowsApplication7.Form1.resources
. This should work. Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
Replace
WindowsApplication7.Form1.resx
withWindowsApplication7.Form1.resources
. This should work. Alexandre Kojevnikov MCAD charter member Leuven, Belgium -
It now works!:) Thanks a Trillion!! You have learned twice!!:) "To teach is to learn twice"
daljv wrote: You have learned twice Indeed :) Alexandre Kojevnikov MCAD charter member Leuven, Belgium