Click here to Skip to main content
15,890,282 members
Home / Discussions / C#
   

C#

 
GeneralRe: Xmodem implimentation Pin
therealmccoy4-Jan-05 14:29
therealmccoy4-Jan-05 14:29 
GeneralRe: Xmodem implimentation Pin
Heath Stewart4-Jan-05 20:12
protectorHeath Stewart4-Jan-05 20:12 
GeneralString output in C# from a C++ dll Pin
vinayakdl4-Jan-05 12:29
vinayakdl4-Jan-05 12:29 
GeneralRe: String output in C# from a C++ dll Pin
Heath Stewart4-Jan-05 13:34
protectorHeath Stewart4-Jan-05 13:34 
GeneralRe: String output in C# from a C++ dll Pin
vinayakdl5-Jan-05 4:53
vinayakdl5-Jan-05 4:53 
GeneralRe: String output in C# from a C++ dll Pin
Heath Stewart5-Jan-05 7:04
protectorHeath Stewart5-Jan-05 7:04 
GeneralRe: String output in C# from a C++ dll Pin
vinayakdl6-Jan-05 9:55
vinayakdl6-Jan-05 9:55 
GeneralRe: String output in C# from a C++ dll Pin
Heath Stewart6-Jan-05 12:04
protectorHeath Stewart6-Jan-05 12:04 
What's the error? I can't really help you if you don't tell me what's wrong.

I can guess, however, that you can't open the somefile.txt from the current directory and you're only opening it for read access, and it won't be created.

The CLR works differently than a typical Win32 EXE (MFC is just a wrapper for Win32 APIs) and what you expect to be the current directory may not be.

Also keep in mind that even with native applications, the current working directory (retrieved by GetCurrentDirectory) is not necessary the directory in which the application is running. If from a console window you execute an application from another directory, the directory which was the current directory is used. For applications launched through shortcuts, if any working directory is specified for the shortcut that is used. There's other cases that will cause the current working directory to be different than the application directory.

To get the application directory, call GetModuleFileName(NULL, szBuffer, MAX_PATH), where szBuffer is a TCHAR szBuffer[MAX_PATH].

Finally, regarding your native code there's a lot of things you should consider changing. Don't use "magic numbers" like 256. What's that mean? Use constants that are more descriptive like MAX_PATH (which is actually 260, and is what Windows defines as the maximum characters in a path). Also don't use unsafe string manipulation functions like strcat that don't ensure NULL termination (which is one major cause of buffer overruns, the most common cause of security vulnerabilies and other types of bugs). MSDN recommends using StrSafe[^], which are safe implementations of string manipulation functions.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralHELP! Web secuirty ... Pin
mrwonkothesane424-Jan-05 11:38
mrwonkothesane424-Jan-05 11:38 
GeneralReplacing text Pin
Christer Claesson4-Jan-05 11:35
Christer Claesson4-Jan-05 11:35 
GeneralSpecial Keyboard keys Pin
BertGo4-Jan-05 10:25
BertGo4-Jan-05 10:25 
GeneralRe: Special Keyboard keys Pin
Heath Stewart4-Jan-05 11:12
protectorHeath Stewart4-Jan-05 11:12 
GeneralRe: Special Keyboard keys Pin
BertGo4-Jan-05 13:00
BertGo4-Jan-05 13:00 
GeneralRe: Special Keyboard keys Pin
Heath Stewart4-Jan-05 13:29
protectorHeath Stewart4-Jan-05 13:29 
Generalstopping service via WMI Pin
thespiff4-Jan-05 8:36
thespiff4-Jan-05 8:36 
GeneralRe: stopping service via WMI Pin
Heath Stewart4-Jan-05 10:51
protectorHeath Stewart4-Jan-05 10:51 
GeneralRe: stopping service via WMI Pin
thespiff5-Jan-05 1:03
thespiff5-Jan-05 1:03 
GeneralRe: stopping service via WMI Pin
Heath Stewart5-Jan-05 4:50
protectorHeath Stewart5-Jan-05 4:50 
GeneralRe: stopping service via WMI Pin
thespiff6-Jan-05 2:19
thespiff6-Jan-05 2:19 
GeneralImplementing mouse panning functionality Pin
Andres Coder4-Jan-05 7:55
Andres Coder4-Jan-05 7:55 
GeneralRe: Implementing mouse panning functionality Pin
Heath Stewart4-Jan-05 11:30
protectorHeath Stewart4-Jan-05 11:30 
GeneralIs this acceptable practice Pin
Wayne Phipps4-Jan-05 7:54
Wayne Phipps4-Jan-05 7:54 
GeneralRe: Is this acceptable practice Pin
perlmunger4-Jan-05 8:41
perlmunger4-Jan-05 8:41 
QuestionHow To Serialize Multiples Refereces to The Same Object? Pin
fmarcos4-Jan-05 7:18
fmarcos4-Jan-05 7:18 
AnswerRe: How To Serialize Multiples Refereces to The Same Object? Pin
Matt Gerrans4-Jan-05 8:03
Matt Gerrans4-Jan-05 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.