[WM] Copy file at runtime to windows directory

Posted on 2009-12-26
Last Modified: 2013-12-27
On my windows mobile 6 application:
My application needs a .dll to be present in the windows directory in order to run.
I have added the file to my project and set it to copy to output but need to copy it to the windows mobile "windows" directory at runtime. How is the best way to do this as i cannot seem to find the windows path as I would using full .NET.

Question by:sdom100
    LVL 24

    Accepted Solution

    just use "\Windows" in or "\\Windows" or @"\Windows" in c#
    LVL 33

    Expert Comment

    This folder always has name "Windows".

    You can install this dll to the windows folder - so the system (wceload) will solve this problem for you.

    Copy a dll in the run-time... You can copy it once and it always be there.

    I think, if the dll will be in the root, the application will work.

    to copy a file from your program you can use CopyFile function:


    Author Comment

    so to clarify,
    on windows mobile installs (WM5, WM6, WM6.5) the \Windows directory is always the same and this approach is not likely to change with WM7 ?
    And thus i would be able to use the CopyFile function to copy the file from the same dir as the executable. Would i need to fully qualify the path for the "from" location in which case how would i do it in WM - can i use reflection to get the path of the .exe ?

    LVL 24

    Expert Comment

    yes, \Windows  will stay the same. even in WM7

    for the current folder: Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
    and yes, you'd need to specify full path

    Author Comment

    I ended up using
    System.IO.File.Copy as CopyFile was not playing ball and this seems like a good managed code solution.

    Author Closing Comment

    Your follow up comment was also very useful

    Featured Post

    Training Course: Android App Development

    This course will involve creating widgets, customize list view, grid view, spinners, etc. Creating applications using audio, video, and SQLite database. Ending with publication on Google Play.

    Join & Write a Comment

    Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator ( This article presumes a wor…
    I recently asked a question ( about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now