|
only two letters away from being an asset
|
|
|
|
|
I like your answer, but the way I understood the question was that you wouldn't know for sure which drive the file is on. (Of course, that is a little weird/ bad design) So if you don't know the drive letter you could acces it through a share. I suppose sometimes I think too much of answering the question instead of pushing for a better design. My fault.
Ben
|
|
|
|
|
If the file is on the same drive that the application is on, could you use
Environment.CurrentDirectory
to figure out which drive you are on. the use relative paths from there to get to your file.
Hogan
|
|
|
|
|
That's a really bad idea. CurrentDirectory is NOT guaranteed to stay that way. Try opening any of the File/Folder dialogs and watch what happens to the current directory during the life of the dialog AND after the dialog. The current directory changes while the user navigates to pick files/folders. The current directory will not return to the original directory when the dialog was shown until after the dialog is dismissed AND the dialog object is told to reset the current directory to what it was when it was shown.
Meanwhile, during the users navigation of the file system, the current directory always changes to match where the user is navigating. If you have a multithreaded app that mistakenly depends on current directory, you've got a huge problem!
|
|
|
|
|
Thanks for the info. I didn't know that!
Hogan
|
|
|
|
|
If you install the file in the same folder, or below, as the exe then you can reference it from there.
InstallDir: d:\MyApp
File path: myfile.txt
InstallDir: d:\MyApp\Files
File path: /files/myfile.txt
only two letters away from being an asset
|
|
|
|
|
How about looking at Application.StartupPath, or Path.GetDirectoryName(Assembly.GetExecutingAssembly.Location).
|
|
|
|
|
Hi,
I am a bit surprised by the answers so far.
For starters you cant hard code C: or D: or whatever.
C: does not even have to exist; I have seen systems that boot and run from D:
Second, you cant use CurrentDirectory, as Dave pointed out.
You can not even use it if you store its startup value,
since one may start an app with its CD preset to whatever value one chooses
(try creating a desktop link, and watch its properties).
third, wherever the app (the exe file) is located, you are not guaranteed that
you can write to that folder. Unless your normal use is only reading that file,
you should choose another place.
The easy way out is by using the special folders, as can be found in
the Environment.SpecialFolder enumeration; you will find some that are
user-independent, others are user-specific.
So I suggest reading up on that class.
|
|
|
|
|
Dear All
Regards!
I found what i want on the link
http://www.codeproject.com/useritems/DrawToolsRedux.asp
but i want the above DrawToolsRedux in OpenGl, i mean that for all drawing part using OepnGL instead CSharp Drawing.
so kindly any 1 who convert the above DrawToolsReduc into OpenGl.
Regrds
David
david
|
|
|
|
|
Hi,
I'm working on inter-process communication between a C++ application and a C# application. I want to transfer string data between them. I'm being blocked by a problem: I don't know how to intercept data (sent from my C++ app) in my C# app. I read I can use GetMessage function, but I dont know how. Here is how I send data from my C++ app to my C# one:
LRESULT copyDataResult;
//CWnd *pOtherWnd = CWnd::FindWindow(NULL, m_otherAppHeader.GetBuffer(m_otherAppHeader.GetLength()));
CWnd *pOtherWnd = CWnd::FindWindow(NULL, "EC");
m_otherAppHeader.ReleaseBuffer();
if (pOtherWnd) {
// Say that we fount ExperienceCreator window
AfxMessageBox("ExperienceCreator is opened.");
COPYDATASTRUCT cpd;
cpd.dwData = 0;
CString txt;
c_TxText.GetWindowText(txt);
cpd.cbData = txt.GetLength() + 1 ;
cpd.lpData = (void*)txt.GetBuffer(txt.GetLength() +1);
copyDataResult = pOtherWnd->SendMessage(WM_COPYDATA,
(WPARAM)AfxGetApp()->m_pMainWnd->GetSafeHwnd(),(LPARAM)&cpd);
txt.ReleaseBuffer();
// copyDataResult has value returned by other app
AfxMessageBox("Info has been sent to ExperienceCreator");
} else {
//AfxMessageBox("Unable to find other application.");
AfxMessageBox("Unable to find EC.");
}
Can you please help me for this problem ?
Thanks.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Just curious why would you want to send a string message between the applications? Sending windows messages would be much more standard way of communicating between applications.
Ben
|
|
|
|
|
You're right. I didn't explain myself correctly.
What I want to do is send string data using windows messages.
Thanks !
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
|
Thanks Kubben !
Pat.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Hello
I've seen your article but I still do not understand How can I intercept a message into one c# application the message will be send from another csharp application using user32.dll API
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam);
|
|
|
|
|
First I need to ask why you want to use sendmessage to communicate between to applications. There are better ways of doing this.
Ben
|
|
|
|
|
Hello
Thank for your reply
No particular reason I just need the best way to send string parameter from one running .NET app to another running one
The second should trigger an event when receiving a message
|
|
|
|
|
Well,
If you just want it to trigger an event in the second app, they my article should work ok. Windows message won't allow you to pass a string in. So if the string it self is important you will have to do something different. If the string has certain characters that should cause something to trigger in the second app, you can just check for those in the first app and then send a windows message.
Let me know if the string is important to the second app or not.
Ben
|
|
|
|
|
Hello Kubben
Yes the string is important
APP A (.NET) is running
APP A require a Form from APP B (.NET) To show user "abc"
So I check if APP B is already running
If NO : I launch it using Process.Start("APP B","abc");
If YES : I want to trigger an event for APP B to show user "abc"
|
|
|
|
|
Well,
You can try using FindWindow to get the second app windows handle. Then you should be able to send a string to it.
There are some examples out there.
I found this one:
http://social.msdn.microsoft.com/forums/en-US/vbinterop/thread/62d0c25f-dadb-4b24-9679-f9f75717456c/
Hopefully, that helps.
Ben
|
|
|
|
|
Thank you
I'll let you now
|
|
|
|
|
hi
i want to show the autogenerated delete button in grid view on some selected rows can anybody help me
|
|
|
|
|
If you only want to show a delete button on certain rows of the gridview you should probably create a template button column that has a delete button. Set the visible = false, then you can in the template you can set the visible property based off some info in the datarow that you are displaying in that row.
The code might be something like:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDelete" runat="server" CommandName="Delete" Text="Delete" Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container.DataItem,"ShowDelete").ToString() == "Yes") %>' />
</ItemTemplate>
This of course assumes that you have a column called ShowDelete and it will contain Yes when you want to show the delete button. So you would probably have to change that part.
Ben
|
|
|
|
|
Hi,
You can use DataGridView control on a windowform.
1) Select the DataGridView control and right click on it.
2) Select the "Add Column"/"Edit Column" option from from the popup menu to define and modify the column types.
3) In the dialog you can define the column. Also you can set the "ColumnType" property as "DataGridViewButtonColumn" for the column you want to display a Delete Button.
4) Please note that you can make these buttons conditionally in-visible.
Manoj
Never Gives up
|
|
|
|
|
hi
i want to show the autogenerated delete button in grid view on some selected rows can anybody help me
|
|
|
|