|
If you have the source for both, you can write ways for the to communicate. If not, it's theoretically possible, but never going to be easy, or reliable. You would basially look for the handles to textboxes and buttons and send them WM_ messages.
Christian Graus
Please read this if you don't understand the answer I've given you
"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 )
|
|
|
|
|
The purpose of the code I am trying to create is to read data from a database. What I am trying to do is (when I run the exe file (on my desktop) of my code) to access my access database (mdb) which is burnt on a CD.
In order to do that I have to know the path of the mdb file.
I dont want to hard code and say D:\test\my.mdb because the driver name can be anything (for instance at my home computer the CD drive is called E:)
So i have 2 questions:
1- What is the code for retreiving the driver name (D or E or etc)?
2- If the user has multiple drivers, is there a way to find out which one s/he put the CD and retreive that driver's name?
Thank you in advance!
|
|
|
|
|
Hi,
here is how:
- get all the drive letters in use from DriveInfo.GetDrives
- for each of them inspect DriveInfo.DriveType
- when equal to DriveType.DCRom, go look for your .mdb file
If your system has multiple CD/DVD drives, and more than one contain a medium with your file,
it is up to you to choose!
FYI: the above would also find virtual CD/DVD drives, like the .iso files opened by
"deamon tools".
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.
|
|
|
|
|
Thanks for the reply Luc,
Do I have to add any libraries under the "using" section, in order to make DriveInfo recognizable?
|
|
|
|
|
Hi 4602860,
you never need using statements, you can always use the fully qualified class name;
you may choose to add a using statement for comfort.
Which one it needs is hidden in the documentation of every .NET class.
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.
|
|
|
|
|
foreach (System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
if (drive.DriveType == System.IO.DriveType.CDRom && drive.Isready)
;
}
Eslam Afifi
|
|
|
|
|
|
You can use DriveInfo.GetDrives Method[^] to retrieve list of drives. Using DriveType property of DriveInfo class you can check whether the drive is Cd drive or not and you can use IsReady property to see if drive is ready or not.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Or you could just ask the user where the data is using an OpenFileDialog...
|
|
|
|
|
Any one tell me How To Put Value at Runtime in DataGrid
|
|
|
|
|
Create some kind of datasource, like a DataTable, and put your data in that, then bind the DataGrid to it.
|
|
|
|
|
Hi,
Is there a metod to hook to CreateWindow, or WM_CREATE in C#?
|
|
|
|
|
|
I use code to insert data from a mdb file into another using the Merge() method of a DataSet...But it's not very effective in terms of performance. Is it possible to use a sql query to directly insert the data? I don't know how to create the code to link the databases.
public void MergeTables(string connS1, string connS2)<br />
{<br />
string connString1 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connS1;<br />
string connString2 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connS2;<br />
OleDbConnection oleConn1 = new OleDbConnection(connString1);<br />
OleDbConnection oleConn2 = new OleDbConnection(connString2);<br />
string cmd1 = "SELECT *FROM db1_table1";<br />
string cmd2 = "SELECT *FROM db2_table1";<br />
OleDbDataAdapter da1 = new OleDbDataAdapter(cmd1, oleConn1);<br />
OleDbDataAdapter da2 = new OleDbDataAdapter(cmd2, oleConn2);<br />
DataSet ds1 = new DataSet();<br />
da1.Fill(ds1, "db1_table1");<br />
da2.Fill(ds1, "db2_table1");<br />
<br />
ds1.Tables["db1_table1"].Merge(ds1.Tables["db2_table1"]);<br />
<br />
foreach (DataRow row in ds1.Tables["db1_table1"].Rows)<br />
row.SetAdded();<br />
<br />
OleDbCommandBuilder cmdBld = new OleDbCommandBuilder(da1);<br />
da1.UpdateCommand = cmdBld.GetUpdateCommand();<br />
@da1.Update(ds1, "db1_table1");<br />
}
Thank you
|
|
|
|
|
To create an exception if you're not going to throw it? I have column level processing, and line level. The LineException has zero to many ColumnExceptions. If I catch an exception on a column, it gets added to the LineException's collection, which will guarantee the throwing of the LineException, but it just 'looks rude' to me to be creating the LineException before any exception is caught.
Pits fall into Chuck Norris.
|
|
|
|
|
Use lazy instantiation to create the LineException on the first ColumnException as in:
private void AddColumnException(ColumnException ex)
{
if (_lineException == null)
_lineException = new LineException();
_lineException.Add(ex);
}
|
|
|
|
|
Brady Kelly wrote: but it just 'looks rude' to me to be creating the LineException before any exception is caught.
I don't know what you mean by rude. Perhaps you mean it makes the code difficult to understand? If so then that is a problem you should fix if possible.
Are these exceptions being thrown by libraries you are consuming? If not and you are checking conditions and throwing the exceptions yourself then you are probably abusing exceptions.
led mike
|
|
|
|
|
I most certainly am abusing exceptions, , although it will in the near future be highly likely that some of them will be thrown by libraries.
Pits fall into Chuck Norris.
|
|
|
|
|
Throwing an empty LineException for no reason would be rude.
If the user never sees the LineException when it contains no ColumnExceptions, then it's not rude.
|
|
|
|
|
You can always throw LineExceptionByTheWayIAmSorry instead.
|
|
|
|
|
hi..i need to add an cursor to my project.I have an cursor file with me(*.cur).How to add it to my project resource and use it as my form cursor.....in normal case we are using 'this.Cursor=Cursors.None' like that...right ?
modified on Thursday, April 10, 2008 9:33 AM
|
|
|
|
|
Hi Friends,
I want to scan the file before upload on the server using c# and .net.
Can anyone help on this.
Please send me the useful link or suggestions.
Thnaks and Rgds
Nithin.
|
|
|
|
|
Of course there's nothing in the naked .NET framework for virus scanning. You'll need to either find a virus scanning API, or alternately, use an existing virus scanner and Process.Start it onto the file you want to scan.
|
|
|
|
|
Is their some sort of doo-dad that I could, e.g. implement the three default constructors on a derived exception? CodeRush?
Pits fall into Chuck Norris.
|
|
|
|
|
Would a Visual Studio code snippet work?
|
|
|
|