📄 153-159.html
字号:
</table>
</form>
<!-- LEFT NAV SEARCH END -->
</td>
<!-- PUB PARTNERS END -->
<!-- END LEFT NAV -->
<td rowspan="8" align="right" valign="top"><img src="/images/iswbls.gif" width=1 height=400 alt="" border="0"></td>
<td><img src="/images/white.gif" width="5" height="1" alt="" border="0"></td>
<!-- end of ITK left NAV -->
<!-- begin main content -->
<td width="100%" valign="top" align="left">
<!-- END SUB HEADER -->
<!--Begin Content Column -->
<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">
<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">
<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE=""> <input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">
</form>
<!-- Empty Reference Subhead -->
<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=6//-->
<!--PAGES=153-159//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="147-153.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="159-162.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
</P>
<H2><A NAME="Heading4"></A><FONT COLOR="#000077">Chapter 6<BR>Working with the Windows CE File System
</FONT></H2>
<P><BIG><BIG>T</BIG></BIG>he concepts of files and directories under Windows CE are the same as on other Windows platforms. A <I>file</I> is defined as a named collection of information. Files can contain data, as do the document files created by a word processor or notepad application. Files can also be executable programs or dynamic link libraries. The essential point is that the file is the most basic unit of storage that allows Windows CE to distinguish one set of data or information from another. A <I>directory</I> is a named group of files or other directories.</P>
<P>Files and directories on a traditional Windows NT or Windows 98 desktop computer have always been closely linked to the presence of permanent storage in the form of floppy disks or hard disks. Computer users are used to using utilities such as Windows Explorer to browse the contents of a physical disk on their own PC or on a PC to which they have access via a computer network.</P>
<P>Devices running under Windows CE do not use floppy or hard disks as storage media. Under Windows CE, files and directories are one of the object types supported by the object store. Files and directories are therefore stored persistently in device RAM, along with databases and database records and the Windows CE registry.</P>
<P>Despite this difference, working with files under Windows CE is very much like working with files under Windows NT or Windows 98 on a desktop PC. Although some file system features are not supported, the file system application programming interface and its semantics are much the same. Hence your understanding of working with the file system API on Windows NT or Windows 98 will go a long way in helping you learn how to work with the Windows CE file system.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>AFTER COMPLETING THIS CHAPTER YOU WILL KNOW HOW TO . . .</B>
<DL>
<DD><B>Create and delete files and directories</B>
<DD><B>Open and close files and directories</B>
<DD><B>Read and write files</B>
<DD><B>Copy files and directories</B>
<DD><B>Rename files and directories</B>
<DD><B>Search for files and directories</B>
<DD><B>Access persistent storage on flash cards</B>
</DL>
<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">The File System Explorer Application</FONT></H3>
<P>The file system programming concepts covered in this chapter will be illustrated with the example of a simple File System Explorer application. The application files are found in the \Samples\filesys directory of the companion CD. The application that is generated by the project is called FILESYS.EXE.
</P>
<P>You can certainly already use the Remote Object Viewer to browse the file system on your Windows CE device or on the Windows CE emulator. But developing an explorer application from scratch is a good way to learn how to use the file system API.</P>
<P>The application interface is a tree view control that displays the contents of the Windows CE file system hierarchically as shown in Figure 6.1. The folder at the top of the tree view display represents the <I>root directory</I> of the file system. All other directories and files reside somewhere under the root directory.</P>
<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/06-05.jpg',480,240 )"><IMG SRC="images/06-05t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-05.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.1</B></FONT></A> The File System Explorer application.</P>
<P>The FILESYS.EXE application allows users to create, delete, and rename files and directories. It also provides very primitive file editing. File properties such as file attributes and file size can also be determined using the application.
</P>
<P>Most of these features are accessed through the Options menu shown in Figure 6.2.</P>
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/06-06.jpg',480,240 )"><IMG SRC="images/06-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-06.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.2</B></FONT></A> The File System Explorer Options menu.</P>
<P><FONT SIZE="+1"><B>Creating and Deleting Files and Directories</B></FONT></P>
<P>To create a new directory with the FILESYS.EXE application, first select the <I>parent directory</I> under which the new directory is to be located. (The term <I>parent directory</I> is used to define the directory under which some specific directory or file is located.) To select a file or directory, tap the name or icon of that file or directory in the tree view display.</P>
<P>After selecting the directory that is to contain the new directory, select the New Directory option from the Options menu (see Figure 6.2). For example, to create a new directory under the root directory, select the root directory icon and select the New Directory menu option. This operation results in the creation of a new directory called Empty Folder, as shown in Figure 6.3. Note the Empty Folder icon.</P>
<P><A NAME="Fig7"></A><A HREF="javascript:displayWindow('images/06-07.jpg',480,240 )"><IMG SRC="images/06-07t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-07.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.3</B></FONT></A> Creating a new directory.</P>
<P>New files are created in much the same way. To create a file under a particular directory, select the directory and then choose the New File option under the Options menu. A file called Empty File will appear. Deleting files and directories is straightforward. Simply select the file or directory you wish to delete, and then select the Delete option from the Options menu.
</P>
<P><FONT SIZE="+1"><B>Renaming Files and Directories</B></FONT></P>
<P>Another common file system operation is renaming files or directories. The names Empty Folder and Empty File are not very useful for real-world directories and files. To rename a file or directory in the File System Explorer application, double-tap on the file or directory to be renamed. A small text entry field appears containing the name of the selected file or directory. You can then type the new file or directory name in this field. Press the Enter key to make the name change take effect. If the application is running on a Windows CE device that does not have a keyboard, simply tap a different part of the screen and your change will take effect.
</P>
<P>As an example, let’s say that you want to change the name of the Empty Folder directory in Figure 6.3 to Acme Corp. Simply double-tap on the name Empty Folder, and type Acme Corp in the edit field. The File System Explorer display should then look as shown in Figure 6.4.</P>
<P><A NAME="Fig8"></A><A HREF="javascript:displayWindow('images/06-08.jpg',480,240 )"><IMG SRC="images/06-08t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-08.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.4</B></FONT></A> Renaming a directory.</P>
<P>Files are renamed the same way. Double-tap the file you wish to rename and type the new name in the edit field that appears.
</P>
<P>For example, let’s create a file called Expenses under the Acme Corp directory. Tap the Acme Corp directory to select it, and then choose New File from the Options menu. A new file, called Empty File, appears under the Acme Corp directory as shown in Figure 6.5.</P>
<P><A NAME="Fig9"></A><A HREF="javascript:displayWindow('images/06-09.jpg',480,240 )"><IMG SRC="images/06-09t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-09.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.5</B></FONT></A> Creating a new file.</P>
<P>Rename this file by tapping it twice and then typing the name Expenses into the edit field that appears. The contents of the Acme Corp directory will then appear as shown in Figure 6.6.
</P>
<P><A NAME="Fig10"></A><A HREF="javascript:displayWindow('images/06-10.jpg',480,240 )"><IMG SRC="images/06-10t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/06-10.jpg',480,240)"><FONT COLOR="#000077"><B>Figure 6.6</B></FONT></A> Renaming a file.<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="147-153.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="159-162.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<br><br>
</TD>
</TR>
</TABLE>
<table width="640" border=0 cellpadding=0 cellspacing=0>
<tr>
<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
<!-- END SUB FOOTER -->
<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- FOOTER -->
<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a> | <a href="/contactus.html"><font color="#006666">Contact Us</font></a> | <a href="/aboutus.html"><font color="#006666">About Us</font></a> | <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> | <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> | <a href="/"><font color="#006666">Home</font></a></b>
<br><br>
Use of this site is subject to certain <a href="/agreement.html">Terms & Conditions</a>, <a href="/copyright.html">Copyright © 1996-1999 EarthWeb Inc.</a><br>
All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
</tr>
</table>
</BODY>
</HTML>
<!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -