|
I'm not sure exactly what you are wanting to do here...however if all you want to do is enumerate the names of the files inside a directory you just need to do this:
string path = Application.StartupPath+@"file path";
.
.
.
string[] files = System.IO.Directory.GetFiles(path);
foreach ( string file in files )
{
... your code ...
}
|
|
|
|
|
Hi,
thanks a lot for your reply. No, Actually I was looking for a solution to use Windows Explorer to open a directory. I found the soltion as
System.Diagnostics.Process.Start("explorer.exe", "\"C:\\Temp\"");
Thanks again.
|
|
|
|
|
Try this:
System.Diagnostics.Process.Start("explorer.exe", "\"C:\\Temp\"");<br />
this code exploring folder C:\Temp
Best regards, Alexey.
|
|
|
|
|
Thank u very much. Exactly thats the VERY solution i was looking for.
|
|
|
|
|
Hello
In my code I am resizing the image. the following is my code:
public void resizeImage(int width, int height, Bitmap bmp){
System.Drawing.Size imgSize = new Size(width, height);
this.image_bmp = new Bitmap(bmp, imgSize);
}
the image gets distorted or I mean that the picyure quality is not
good.
what other things can we do to get good quality pictures
Deepak Anish
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
Create a Bitmap with the desired size, create a Graphics object for it and use that to draw the bitmap onto it. Set the SmoothingMode property of the graphics object to SmoothingMode.HighQuality to get the best drawing quality.
If you are enlarging the image, you can't expect a very good result. Even if the image is larger, it doesn't contain more image information than the original image.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I made my Windows C# program with SQL Server 2005 Express. Now when i will ship this software to my client's pc, and if he has SQL Server professional or developer edition, will my Software work or He must install SQL Server Express edition to run my software ?
Thanks
|
|
|
|
|
emran834 wrote: will my Software work or He must install SQL Server Express edition to run my software ?
Your software ought to work and your client should not have to install SQL Server Express. I hope your software works for your client
Paul
|
|
|
|
|
As long as you have externalized your connection string from your program, then you will not have any problems accessing any form of Sql Server.
|
|
|
|
|
Hi guys.Got a fractional function like the form y=(a0*s+a1*s+a2*s)/(b0*s+b1*s+b2*s).I put (a0,a1,a2)in txtNumer and(b0,b1,b2)in txtDenom like in the code below.What I have to write in txtFunction so I get as result in textbox the function.Or Im in a wrong path??Help please...
private void txtNumer_TextChanged(object sender, EventArgs e)
{
string numerator = String.Empty;
if (txtNumer.Text != String.Empty)
{
//put the text of textbox into a string
string source = txtNumer.Text;
//ndaje tekstin ne copat midis presjeve - per ekte na duhet nje array of strings
//se nuk e dime sa numra kemi shtypur ne tekst
string[] pieces = source.Split(',');
int[] numbers = new Int32[pieces.Length];
//we need an array of int or double to get numbers we put in textbox
//so we can convert them
for (int i = 0; i < pieces.Length; i++)
{
numbers[i] = System.Convert.ToInt32(pieces[i]);
}
}
}
private void txtDenom_TextChanged(object sender, EventArgs e)
{
string denominator = String.Empty;
if (txtDenom.Text != String.Empty)
{
//put the text of textbox into a string
string source = txtDenom.Text;
string[] pieces = source.Split(',');
int[] numbers = new Int32[pieces.Length];
///we need an array of int or double to get numbers we put in textbox
//so we can convert them and put them in output textbox
for (int i = 0; i < pieces.Length; i++)
{
numbers[i] = System.Convert.ToInt32(pieces[i]);
}
}
}
private void txtFunction_TextChanged(object sender, EventArgs e)
{
}
}
|
|
|
|
|
Any one used it from C#? Comments.
Also their login/create user accounts is disabled. Any other sources for the sdk? I am just looking at reading the files to make web reports from.
Thanks, Mike
"Every new day begins with possibilities. It's up to us to fill it with things that move us toward progress and peace.” (Ronald Reagan)
|
|
|
|
|
Hi!
I have made an application that connects to a sql server by using the "add data source" method...all the connections have been made with datasets and everything is working.
What i would like to do is to be able to change the connection string, as it is now the connection string is set by c#
(Settings.settings = (Connection string),(Application scope),(Value=Data Source=VM2\SQLEXPRESS....)
however i would like to list all sql servers before login and when user clicks one of the sql servers listed, the connection should be made to this server and then continue with the login.
I have successfulla made a list of the names of the sql servers, but i know too little about how to change the connection settings.
In short, what i want to do is being able to within the program change the Value of the Data Source. I realize this may have to make me create a configuration file, but that is ok.
Can somebody please help me with a codesnippet to run before the connection is made or something?
Greatly appreciated
/nami
|
|
|
|
|
Here is one possible approach:
myapp.exe.config
<br />
<add key="ServerLocation", value=@"...path ..."><br />
here is my code snippet
[Serializable]
public class Servers:List<ServerData>
{}
[Serializable]
public class ServerData
{
string name;
string connection;
public string Name { get; set; }
public string Connection { get; set; }
}
public class myapp
{
...
string location = { depends on framework version as to how you
get your configuration setting }
...
FileStream stream = new FileStream( location, FileMode.Open );
XmlSerializer ser = new XmlSerializer ( typeof( Servers ) );
Servers serverList = ser.Deserialize( stream );
foreach ( ServerData connectionString in serverList )
{
myListBox.Items.Add ( connectionString.Name );
}
That should get you started.
-- modified at 0:15 Wednesday 19th April, 2006
|
|
|
|
|
Hi!
Im currently at work so i cant try that code, but looking at the code i cant really see where it changes the value of the connectionstring already made? this is really the only problem i have with my code so if you could point it out a little better for me it would be greatly appreciated as i'm a newbie
Thank you for your answere!
|
|
|
|
|
Once you have your desired connection string you then create the connection. You do not want to have it hang around long since this is a rare resource. So you just use it, get what you need, and close the connection. You keep the connection global to your application. If a database is changed it is just a matter of creating a new Connection object.
|
|
|
|
|
Once again, thank you for your answere... I realize the problem of having the connection string hang around, but i think you may have misundestood me. The connection to the database is not made by the IP address of the SQL server, but rather the name of the server, for instance VM2\MSSQL... I do not want to have to recompile the program for every distribution since the name of the sql server may change, thats why i want to be able to change precisly that string that is created by c# so that it is changable within the program before making the connection, instead of having to recompile and distribute the program for each name the server may have.
Please correct me if i did not understand your post properly, thankfull for your help!
|
|
|
|
|
In my first post I indicate how you have a program config setting which points to the location of the collection of connection strings.
config ---> directory of XmlSerialized connection string object.
| |
v |
Program <-------------------------
The serialized object are as follows:
<Servers>
<Connection name="" connString="" />
<Connection name="" connString="" />
</Servers>
In the collection of connection strings (existing outside of the program) part of the string is server="". So you just need to change the server part of each connection string without the need to recompile the program. And if you need to move the directory that holds these definitions, just change the application config file to point to the new location.
-- modified at 12:59 Thursday 20th April, 2006
|
|
|
|
|
I am using visual studio 2003 .
i downloaded the directx 9 SDK and installed it.
according to many tutorials i should see the directx 9 libreries in the list
when i do add refference but i still dont see those namespaces in the list.
can anyone help?
|
|
|
|
|
First you should check to see if you properly installed. Assuming you did the default installation, you should see the DirectX folders at :
C:\WINDOWS\Microsoft.NET\Managed DirectX
There will be a subdirectory for each version of DirectX you have installed.
After that it is a simple matter of running VS, opening your project, doing and Add Reference, and scrolling down to Microsoft.DirectX.
|
|
|
|
|
Please bear with me, this posting is long. I hope somebody has some good ideas here.
My company has a C++ application (call it MyApp) that is allowed to be spawned by a number of 2nd applications. The 2nd application runs MyApp, then registers a special message type and sends the message. I don't have the source code for MyApp (It was before my time). Some ofthe 2nd applications are developed by other companies, but I have the source code for one of them. The 2nd application actually has 2 sections of code where it spawns MyApp. One of them uses:
UINT WM_MYMESSAGE = RegisterWindowMessage("My Special Message");<br />
WinExec("MyApp", SW_SHOW);<br />
SendMessage(HWND_BROADCAST, WM_MYMESSAGE, (WPARAM)m_hWnd, 0L);
the other uses CreateProcess instead of WinExec.
MyApp, when starting up, also registers the message type, then listens for the message and processes it when it is received. MyApp also makes sure that there is only one instance of itself running. If, during startup, it sees another instance out there, it brings the other instance to foreground, restores it if minimized, and then quietly kills itself. Therefore, MyApp receives and processes the message sucessfully if it was already running when the 2nd application sent the message, or if it was not yet running.
Cut to the present. We have recoded MyApp into C#/.NET environment, and we need this behavior to still work the same, without any change to the 2nd applications. MyApp is a Windows.Forms application, and one of the first things it does in Main() is call
static UInt32 WM_MYMESSAGE = RegisterWindowMessage("My Special Message");
next, it creates an instance of the main form:
Form myApp = new MyApp();
then, after performing other startup tasks, it runs it:
Application.Run(myApp);
The main form has an override of WndProc() which does pretty much this:
protected override void WndProc(ref Message m)<br />
{<br />
if(m.Msg == WM_MYMESSAGE )<br />
{<br />
ProcessMyMessage( m.WParam,m.LParam); <br />
}<br />
base.WndProc(ref m);<br />
}
This version of MyApp also prevents multiple instances of itself from running in the same way the C++ version did.
The problem I have is that the C# version correctly receives and processes the special message only when it is already running. When it is not running, it starts up, but the main form never receives the message. I am not sure at this point whether the delay in starting the app means that the message is already gone before MyApp is ready to receive it, or if there is something else going on. It is a fairly large application and takes about 5 to 7 seconds to start up on an average machine. Most of the applications that spawn MyApp are sending the message either immediately after spawning, or waiting at most 5 seconds before sending it. The C++ version works beautifully on fast or slow machines, but the C# version only works when it is already running (even on fast machines).
I have wrestled with this problem for awhile without success. If anybody can shed some light on this I would be most grateful.
Thanks for any help.
Steve
|
|
|
|
|
Hi,
I'm trying to cast a string to a custom type as follows:
msgType = (MessageType) stringArray[2];
but darn .Net keeps telling me it cannot convert type 'string' to 'Server.MessageType'. Any ways around this?
Prob a very simple problem, but any help much appreciated.
|
|
|
|
|
No. You can't just cast a String object to some complete different class. You can only cast an object to it's actual class or any class or interface that it inherits.
What kind of class is Server.MessageType? Why would you think that you could cast a string to that class?
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a problem with the exception "Value does not fall within the expected range" and I haven't quite figured out what is wrong in my code.
I have a store procedure that has a declared char for input. The store procedure is used by a Crystal Report filename.
I want to pass a char from C# application that calls the Crystal report and passes a character to it.
Somehow, I got the exception.
I wonder if the character type in VS .Net 2005 is not compatible with a character type in SQL Server 2000.
Any help? Thanks.
Kyah
|
|
|
|
|
It is not really clear in your post just what your are doing and who is generating the problem. You talk about Crystal reports and that is one source of errors, AND you talk about VS vs. SQL Server.
To try and fire some help in the dark -- you will probably have to talk to your DBA first before talking to us. You may also need to go into more details as to how this character is defined, who it is passed to, and so on. Basically, when a problem occurs you need to investigate all aspects of every possible endpoint that generates a potential error.
For example: a character is normally a character. However if you have a setting somewhere (or a type definition) that defines a character as being UNICODE then you will need to consider the fact that you are passing a UNICODE character into a database that is defined as ASCII instead of UNICODE.
However with Crystal Reports in the middle, the error could be from Crystal -- but you don't say. You also do not indicate if the call into the Crystal thing has worked in prior versions of VS or not. That can make a huge difference in the cause of the problem.
Do the homework and then try asking the question after you have done so.
|
|
|
|
|
Hi,
I have a problem with the exception "Value does not fall within the expected range" and I haven't quite figured out what is wrong in my code.
I have a store procedure that has a declared char for input. The store procedure is used by a Crystal Report filename.
I want to pass a char from C# application that calls the Crystal report and passes a character to it.
Somehow, I got the exception.
I wonder if the character type in VS .Net 2005 is not compatible with a character type in SQL Server 2000.
Any help? Thanks.
Kyah
|
|
|
|