• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1850
  • Last Modified:

Windows CE Is there a function to Change Directory ?

I found CreateDirectory() and RemoveDirectory() but cannot find anything to Change Directory !
and _chdir() is not supported.

Using Window CE not the .net version


0
hansw77041
Asked:
hansw77041
  • 8
  • 4
  • 2
  • +1
1 Solution
 
Jaime OlivaresSoftware ArchitectCommented:
Have not found too. I use to store current directory in a global variable and append to filename every time I need it.
0
 
hansw77041Author Commented:
OK thanks sounds like you are looking for the same soltuion.
I hope some one can tell US the correct way to do this... :-)
0
 
Jaime OlivaresSoftware ArchitectCommented:
Well, I have 8 years programming with windows CE. Don't expect so.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Jaime OlivaresSoftware ArchitectCommented:
By the way... SetCurrentDirectory() and GetCurrentDirectory() WinAPI functions are also not supported.
0
 
jimwassonCommented:
MoveFile() doesn't do it? I haven't tried it but it's supposed to rename directories, too.
0
 
hansw77041Author Commented:
OK I'll wait a day or two to see if anyone has found a soltuion.
0
 
Jaime OlivaresSoftware ArchitectCommented:
Then I recommend to put a link to this question in the WindowsCE TA:
http://www.experts-exchange.com/Programming/Wireless_Programming/WinCE/
0
 
Jaime OlivaresSoftware ArchitectCommented:
Jim,
I think Hans want to change current directory, not to change directory's name.
0
 
jimwassonCommented:
Oops.
0
 
AxterCommented:
If you don't want to store the current directory in a fix string literal, you can use something like the following:

TCHAR T_szHomeDir[MAX_PATH];
 GetModuleFileName(GetModuleHandle(NULL),T_szHomeDir,MAX_PATH);
 for(i=_tcslen(T_szHomeDir); i && T_szHomeDir[i]!=TEXT('\\');i--);
 T_szHomeDir[i+1]=TCHAR('\0');

Now T_szHomeDir should have the current executable directory, and all you have to do is add a relative path to get to your target directory.
0
 
Jaime OlivaresSoftware ArchitectCommented:
Usually data in WindowsCE programming style (I mean, according to Microsoft recommendations) is not stored at current executable directory branch but at internal RAM's MyDocuments directory or internal/external Flash Memory's MyDocuments directory. This is due to that many WinCE options like backup and sync are "tied" to those directories.
So, it is not a good practice to use GetModuleFileName() in this case, while could be good for desktop Windows.

0
 
Jaime OlivaresSoftware ArchitectCommented:
Take a look to this MSDN page:
http://msdn.microsoft.com/library/en-us/wcefiles/html/_wcesdk_Using_the_File_System.asp

This is the most important paragraph:
"Windows CE uses a variety of techniques to simplify memory management and to reduce memory overhead. First, Windows CE ***does not use the current directory concept***. Instead, all of the references to an object are given in the full path. Further, Windows CE automatically compresses all of the files in the object store; therefore, no file has a flag to indicate compression. Of course, a flag does exist that distinguishes between a file in ROM and a file in RAM."

This will explain why you and me won't never find any facility to get "current directory".
0
 
hansw77041Author Commented:
Thanks for the research.
I just built a Dir Browser and that allows the user to "build" a string by browsing for the Current working direcory.

That solved the problem I had with not being able to us hard coded paths. The reason is the user must be allowed to make any directory on the SD storage card and
then be able to set the path to it.

I think MS are short sighted in this ***does not use the current directory concept*** !

Thanks again.

0
 
Jaime OlivaresSoftware ArchitectCommented:
There are more short sights in MS Windows CE concept, by example, the lack of file extention view. I think it's really annoying for a mid- or high-skilled user. But still love it because you can port small and medium desktop Windows applications with minimum pain.
Thanks for the points,
BR,
Jaime.
0
 
hansw77041Author Commented:
Yep... I agree.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now