|
string originalPath =System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
will this work for you.
this gives full path of ur exe file u have to parse to get the path only.
|
|
|
|
|
Application.ExecutablePath, I believe. It's something like that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you both, I tried
Christian Graus wrote: Application.ExecutablePath,
and it work just fine, I'll try other method too.
Does anyone know maybe why XMLTextWriter write file who know where sometimes if only file name is specified (and it's almost random, sometimes it end up where it need to be)?
This way it work fine
|
|
|
|
|
If you don't specify a path, the working directory will be used. It's usually the same, but not always.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Yeah for example if array list is same on serialization like one I deserialized in (data didn't change) than it remain same, but if I added something to it... then it isn't go figure...
|
|
|
|
|
I use Application.StartupPath...
|
|
|
|
|
I'll try this also... although other solution work nice... but as they say there is always more than one way to do something in programming
|
|
|
|
|
Try Application.ExecutablePath
There is also and another property which return the applications folder. Sorry currently i don't have access to VS
|
|
|
|
|
kinda' late but maybe it will help ... Application.StartupPath
|
|
|
|
|
Radu Sorin wrote: kinda' late but maybe it will help ... Application.StartupPath
Thanks... it's not late all things I do in C# for now are only my learning so more I know better...
I'll implement all options to see if there is any difference...
|
|
|
|
|
I have a bitmap (300x471) which I added as a resource.
I wanted to modify the bitmap and display it.
My picture box control has also same dimensions. (300x471)
void Smile_Load(object sender, System.EventArgs e)
{
_Background = Book.CSharp.Properties.Resources.Monaliza;
_Final = new Bitmap(_Background.Width, _Background.Height);
Graphics fg = Graphics.FromImage(_Final);
fg.DrawImage(_Background, 0.0F, 0.0F);
fg.Dispose();
pictureBox1.Image = _Final;
}
problem: If I give picture box actual bitmap (pictureBox1.Image = Background) it fits inside the control.
But if just copy to new bitmap, then it does not fit and control scales to bigger bitmap and only show partially which is very annoying.
I looked different articles and it looks perhaps this is done by AutoScaleDimensions
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
I played and also even removed, but no effect.
Any idea?
A prompt answer will be very appreciated.
agha.khan@hotmail.com
Agha Khan
|
|
|
|
|
Yep, I would suspect the automatic scaling.
Maybe you can replace
fg.DrawImage(_Background, 0.0F, 0.0F);
by
fg.DrawImageUnscaled(_Background, 0.0F, 0.0F);
FYI both also accept int coordinates, no need for floats here.
Luc Pattyn
|
|
|
|
|
Thank you for prompt reply.
But it did not work.
Agha Khan
|
|
|
|
|
Some ideas:
I do not know what is happening, you could check if the result has anything to do
with your scaling, just try to see what percentage of width and height is drawn...
You should try to figure out which part fails: the copying of the bitmap, or the
picturebox showing the image.
You dont need the Graphics to copy the bitmap, you could simply do
_Final=new Bitmap(_Background);
check if this works OK, if so you can still create a Graphics for it and modify it at will.
Luc Pattyn
|
|
|
|
|
Thank you.
I did not have much control on Picture box, so I changed control to
partial class Display : System.Windows.Forms.Panel
And override the paint function.
As for as display is concern, it worked fine, but scaling problem still persist.
As you suggested I used
_Final=new Bitmap(_Background);
And I looked the dimensions of bitmap and they are correct.
Only when I look at it is wrong.
When I increase the size of display I can see the whole, but bigger bitmap.
Best regards
Agha Khan
Agha Khan
|
|
|
|
|
The bitmap is drawn with the same physical size. That size is expressed in inches and not pixels. As the new bitmap that you have created does not have the same resolution (pixels per inch) as the bitmap that you are drawing, it will be drawn at a different pixel size.
You can either set the resolution of the new bitmap to the same as the bitmap that you are drawing (or the other way around if you like):
_Final.HorizontalResolution = _Background.HorizontalResolution;<br />
_Final.VerticalResolution = _Background.VerticalResolution;
or you can draw the bitmap specifying the pixel size:
fg.DrawImage(_Background, 0, 0, _Background.Width, _Background.Height);
---
Year happy = new Year(2007);
|
|
|
|
|
Perhaps I need more experiments, but it looks it works.
Thank you everyone.
Best regards,
Agha Khan
|
|
|
|
|
I'm currently trying to create an OpenDialog that is similar to the Windows Explorer in appearance.
(TreeView on the left, ListView on the right)
To get the logical drives is pretty simple. I just use the Directory.GetLogicalDrives() method.
However, I didn't find anything similar to access network drives, like in the Network-node
in the Windows Explorer TreeView.
I found a few solutions, that take hundreds of lines of code to get the result, that this one method
achieves for the logical drives.
Is there no shorter way? If there is one, what is it?
|
|
|
|
|
Is there a reason why you're not using the common OpenFileDialog? Unless there is some technical reason or compelling user scenario for not doing so, I'd suggest using the common Windows dialogs because they help to keep a consistent user interface across applications and therefore breeds familiarity for the user. In addition, if Microsoft decides to revamp the dialogs, your application will automatically inherit the improvements. Plus, it's a lot less work.
Anyway, just my humble opinion. I realize that the common dialogs won't work well in every possible situation.
-Phil
|
|
|
|
|
The common OpenFileDialog can't be modified (At least not without some rather complicated hacking.).
I just thought it would be a lot nicer to have one dialog instead of using the common dialog and opening a custom dialog upon closing the common one, to ask the user for all the remaining settings.
With my custom OpenDialog filtering is a lot more flexible. I can not only filter files by their ending, but also display them in the listView without it.
|
|
|
|
|
Hi all,
I have a large processing job that is taking an hour or two. I have a simple form that contains a statusbar panel that informs the user with progress. At the moment the update is a text string but I might move to a progress bar in the future. However, the main question is this:
If I click elsewhere (outside the program) and then return focus to the form, the statusbar text does not redraw and update. It ends up stuck on wherever it was when I left it. Furthermore, it even does this if I simply move the form slightly without losing focus.
Can someone advice what to do to maintain the updates?
TIA
Jerry
|
|
|
|
|
Are you doing your processing in the same thread as the GUI runs in? It sounds like it. If so, you have two options - you can either break out your processing to another thread, or you can simply make sure you call Application.DoEvents() regularly.
Hope that helps
|
|
|
|
|
Application.DoEvents() fixed it! Thanks!!
|
|
|
|
|
Im using a 3rd party DLL to create a graph. When calling some methods within this DLL i get exceptions because the control is running in a internet trusted zone. I do not have access to the 3rd party DLLs code so i cant add 'new UIPermission().Assert();' statements within the DLLs.
Is there a tool/way of signing a DLL so it will be trusted? i already sign the DLLs with my certifcate.
Regards,
Gareth.
|
|
|
|
|
The 3rd party company fixed the problem for me by removing some offending code.
Regards,
Gareth.
|
|
|
|