|
|
Well that answers that. Thanks Heath.
I'm curious what google query you used, i tried searching before i came here.
|
|
|
|
|
|
FolderBrowserDialog long path
The first search result was on the Microsoft Support site.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
We are building a windows application that needs to look at an .ini file when the program first starts. We have no problem reading the ini file once the app starts up by hard-coding the name of the file, but I would like to be able to dynamically direct the app to the correct ini file when it starts up. Specifically, the main differences between the 2 .ini's would be which database that the app should be using, and whether we are in a test mode or live mode. This would make switching between testing and live use quick, without having to recompile.
So the question is, is there a way to have the properties under the desktop icon be something like "myprogram.exe test.ini" or "myprogram.exe live.ini"
Thanks much for the help...
Alan Berger
|
|
|
|
|
You mean a shortcut? Yes, just type the filename in the Target: field for the shortcut properties after the program. Make sure that Start in: (working directory) field is set to the program directory or the directory where your program looks for files (so for files you access without an absolute file path (start from the drive root), they resolve to this directory). Declare your entry point (Main ) using Main(string[] args) . The filename gets passed as an argument.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
aberger56 wrote:
So the question is, is there a way to have the properties under the desktop icon be something like "myprogram.exe test.ini" or "myprogram.exe live.ini"
In short, yes, your application can take arguments which is why you can write Main as such. I would suggest you look at other options such as extracting the path from a config file.
public static void Main(string[] args)
{
string path = args[0];
if(path != null)
{
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Heath and Nick:
Thanks very much for your quick and even more importantly, correct, answers. I truly appreciate it!
ab
|
|
|
|
|
Hi all,
I have a program, that is just supposed to open as a server (i.e. listen for connections) and i run it, and it pauses... then i try to move something and the dreaded program not responding error comes up.... I'm new to c# and don't quite understand why this does this. Another side note.. the designer doesnt work now since i added my inner namespace Tito_Network, which handles the networking calls...
here is my code..
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication4<br />
{<br />
namespace Tito_Network<br />
{<br />
using System;<br />
using System.Text;<br />
using System.Net;<br />
using System.Net.Sockets;<br />
using System.Windows.Forms;<br />
<br />
public class Listen<br />
{<br />
<br />
public Listen(TextBox one, TextBox two) {<br />
IPAddress ip = IPAddress.Parse("127.0.0.1");<br />
TcpListener tcp = new TcpListener(ip,2486);<br />
tcp.Start();<br />
<br />
one.Text +="Server Activated...\n";<br />
<br />
Socket soc_Client = tcp.AcceptSocket();<br />
<br />
try<br />
{<br />
if(soc_Client.Connected)<br />
{<br />
while(true)<br />
{<br />
one.Text +="Client connected from"+soc_Client.AddressFamily;<br />
}<br />
}<br />
}<br />
catch(Exception s)<br />
{<br />
MessageBox.Show(s.ToString());<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
#region Private Form Variables<br />
private System.Windows.Forms.TextBox textBox1;<br />
private System.Windows.Forms.TextBox textBox2;<br />
private System.Windows.Forms.MainMenu mainMenu1;<br />
private System.Windows.Forms.MenuItem menuItem1;<br />
private System.Windows.Forms.MenuItem menuItem2;<br />
private System.Windows.Forms.MenuItem menuItem3;<br />
private System.Windows.Forms.MenuItem menuItem4;<br />
private System.Windows.Forms.MenuItem menuItem5;<br />
private System.ComponentModel.Container components = null;<br />
#endregion <br />
<br />
#region Initialization and Disposal<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
#endregion <br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.textBox1 = new System.Windows.Forms.TextBox();<br />
this.textBox2 = new System.Windows.Forms.TextBox();<br />
this.mainMenu1 = new System.Windows.Forms.MainMenu();<br />
this.menuItem1 = new System.Windows.Forms.MenuItem();<br />
this.menuItem2 = new System.Windows.Forms.MenuItem();<br />
this.menuItem3 = new System.Windows.Forms.MenuItem();<br />
this.menuItem4 = new System.Windows.Forms.MenuItem();<br />
this.menuItem5 = new System.Windows.Forms.MenuItem();<br />
this.SuspendLayout();<br />
this.textBox1.AutoSize = false;<br />
this.textBox1.BackColor = System.Drawing.SystemColors.WindowText;<br />
this.textBox1.ForeColor = System.Drawing.Color.Lime;<br />
this.textBox1.Location = new System.Drawing.Point(16, 184);<br />
this.textBox1.Name = "textBox1";<br />
this.textBox1.ReadOnly = true;<br />
this.textBox1.Size = new System.Drawing.Size(384, 136);<br />
this.textBox1.TabIndex = 0;<br />
this.textBox1.Text = "textBox1";<br />
this.textBox2.AutoSize = false;<br />
this.textBox2.BackColor = System.Drawing.Color.Black;<br />
this.textBox2.ForeColor = System.Drawing.Color.Lime;<br />
this.textBox2.Location = new System.Drawing.Point(472, 184);<br />
this.textBox2.Name = "textBox2";<br />
this.textBox2.ReadOnly = true;<br />
this.textBox2.Size = new System.Drawing.Size(80, 136);<br />
this.textBox2.TabIndex = 1;<br />
this.textBox2.Text = "textBox2";<br />
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
this.menuItem1,<br />
this.menuItem3});<br />
this.menuItem1.Index = 0;<br />
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
this.menuItem2});<br />
this.menuItem1.Text = "File";<br />
this.menuItem2.Index = 0;<br />
this.menuItem2.Text = "Quit";<br />
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);<br />
this.menuItem3.Index = 1;<br />
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {<br />
this.menuItem4,<br />
this.menuItem5});<br />
this.menuItem3.Text = "Connections";<br />
this.menuItem4.Index = 0;<br />
this.menuItem4.Text = "Obtain Clients";<br />
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);<br />
this.menuItem5.Index = 1;<br />
this.menuItem5.Text = "Deactivate Client";<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(576, 333);<br />
this.Controls.Add(this.textBox2);<br />
this.Controls.Add(this.textBox1);<br />
this.Menu = this.mainMenu1;<br />
this.Name = "Form1";<br />
this.Text = "Tito v1.0";<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
<br />
#region App Main<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
#endregion<br />
<br />
#region Event Handlers<br />
private void menuItem2_Click(object sender, System.EventArgs e)<br />
{<br />
if(MessageBox.Show("Are you sure you want to quit?","Tito v1.0",<br />
MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)== DialogResult.OK)<br />
{<br />
Application.Exit();<br />
}<br />
}<br />
<br />
<br />
private void menuItem4_Click(object sender, System.EventArgs e)<br />
{<br />
Tito_Network.Listen l = new Tito_Network.Listen(textBox1,textBox2);<br />
}<br />
#endregion <br />
<br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|
AcceptSocket is a blocking call. It will stop execution until a connection is received. This is why you should start a new thread (see the Thread or ThreadPool class in the .NET Framework SDK) to listen for connections so that the UI is not affected.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I posted a thread yesterday about thumbnails that I was trying to create that took my PF usage up to an entire gig, well Nick Parker solved my problem, Thanks man.
However, now that that is solved I want to speed up the thumbnails. It takes about 30 seconds to get 64, 5 megapixel pictures resized to be 100,100. The code I'm using is as follows:
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap TemporaryBitmap = new Bitmap(ImageFileNames[a]);
ListOfImages.Images.Add(tempBitmap.GetThumbnailImage(100,100,myCallback,IntPtr.Zero));
tempBitmap.Dispose();
TemporaryFilePaths.Add(temps[a]);
It's continually looped to get each picture in the folder and adds them to a List View. Any idea's how I can speed up the time because this will eventually be reading of off flash cards and that'll take even longer. Any help would be greatly appreciated thanks.
|
|
|
|
|
Does specifying the image size of 100, 100 in the TemporyBitmap constructor help?
|
|
|
|
|
No it doesn't, that had been my origonal plan but it did the same thing. There's definitely a way because I've tested several programs and they were able to do it in a matter of seconds. Plus windows is able to create the thumbnails quickly too. I think there has to be some other command that I'm missing.
|
|
|
|
|
Another thought, again untested!
Does using the Image class instead of the Bitmap class for the tempory image help?
|
|
|
|
|
A couple of thoughts, first off, I would assume you are going to copy over the files from the flash card before you start your conversion process. You might also consider doing the two items (copying files and converting to thumbnails) on separate threads. You could have a thread that watches the folder you are placing the images in (using the FileSystemWatcher class, specifically the Created event) and then have another thread process the new image to a thumbnail.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hiya I have a normal web app with many forms.
My problem is that when I close the web app with the red X in internet explorer, Application_End in Global.asax does not get called to clean up my varibles.
Am I doing something wrong??
Thanks
|
|
|
|
|
IrishSonic wrote:
Am I doing something wrong??
You dont expect your visitor to shutdown the web site now?
top secret xacc-ide 0.0.1
|
|
|
|
|
First of all, this question belong in the ASP.NET forum, but since it's a simple question I'll answer it here anyway.
The red X in IE (or any browser) does nothing on the server. HTTP is a client-request/server-response mechanism and only client-side scripting events would know that your browser is closing.
Also, if you read the documentation for ASP.NET (always a good thing), the Application_End handler executes when your ASP.NET web application is shutting down (as leppie tried to point out with little extra helpful information). Each client does not get a separate instance of a web application - that would be stupid (wouldn't scale well, among many other things). Each additional client gets a separate context (a thread), optionally with a session attached. If you want to store information per-client and clean it up, use the Session property found on many objects (like HttpContext , Page , et. al.) and handle clean-up in the Session_End handler in Global.asax. This still won't fire when a user closes the browser, however. It will fire when the session is destroyed. The default is in 30 minutes.
Please direct future questions to the appropriate forums. This is an ASP.NET related question - it doesn't matter if you wrote it in C# or not; C# is just one many languages that target and use the .NET Framework.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can i make a today screen component to my project. i know that it made by microsoft embeded visual c++. but i had no information about this tool. can any one help me with any info. or samples about this.
and how can i handle WM_ERASEBKGND message to make this component has a transparent back ground.
can any one help me,please.
Mohamed Elsaid - Faculty of computers and information - Helwan university - Forth year - Cairo - Egypt
|
|
|
|
|
Create a new form, place a TextBox on it, setting the Multiline property to true . Add some Button s that allow you to scroll through your data which can be stored in any mechanism you wish (XML file, database, etc). This should get you started, any other questions feel free to ask.
- Nick Parker My Blog | My Articles
|
|
|
|
|
A today screen component is the little apps that run on a today screen of a PocketPC device, like the calendar, inbox, and more (I have one that MS Money added).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Damn, I thought he was talking about the Tip of the Day and just misworded it.
- Nick Parker My Blog | My Articles
|
|
|
|
|
If you have questions about Microsoft eMbedded Visual C++, I suggest you post them in the C++ forum. If you look in the Windows Mobile SDK, there's also a sample about writing a today screen component.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I made it using CAB+INF.
Mohamed Elsaid - Faculty of computers and information - Helwan university - Forth year - Cairo - Egypt
|
|
|
|
|
How can i make the uninstallation delete all my application files, the help files and the database asociated with the program. and how can i use uninstall_init() and uninstall_exit() functionality to clean up data files and databases.
can any one help me,please.
Mohamed Elsaid - Faculty of computers and information - Helwan university - Forth year - Cairo - Egypt
|
|
|
|