472,993 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

C# WinCE-App: problem in marshal findfirstfile in c# win ce device

4
hello everybody

I am having a very wierd problem.i am developing a win ce applicationin which I am marshalling win ap function findfirstfile and findnextfile in c# .My problem is it reads the file name but it misses the first 2 characters of each file name.I have no idea why .Please help.
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Runtime.InteropServices;
  9.  
  10.  
  11. namespace dummy2
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         int rfidTagHandle;
  16.         Win32Methods.WIN32_FIND_DATA FindFileData;
  17.  
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             //for (int i = 0; i <= 2; i++)
  27.             //{
  28.             rfidTagHandle = Win32Methods.FindFirstFile("*.*", out FindFileData);
  29.                 //"\\RFID\\[.]"
  30.                 if (rfidTagHandle == Win32Methods.INVALID_HANDLE_VALUE)
  31.                 {
  32.                     MessageBox.Show("FindFirstFile failed");
  33.  
  34.                 }
  35.                 else
  36.                 {
  37.  
  38.                     String fileName = FindFileData.cFileName;
  39.                     //MessageBox.Show("File name length is" + FindFileData.cFileName.Length.ToString());
  40.                     //textBox1.Text = "Application" + "\r\n";
  41.                     textBox1.Text = textBox1.Text + fileName + "\r\n";
  42.                 }
  43.  
  44.                 while (Win32Methods.FindNextFile(rfidTagHandle, out FindFileData) != false)
  45.                 {
  46.                     String fileName = FindFileData.cFileName;
  47.                     textBox1.Text = textBox1.Text + fileName + "\r\n";
  48.                     //MessageBox.Show("next File name is" + fileName);
  49.                     //listView1.Items.Add(fileName); 
  50.  
  51.                 }
  52.                 MessageBox.Show("FindnextFile failed");
  53.                 Win32Methods.FindClose(rfidTagHandle);
  54.            // }
  55.         }
  56.     }
  57.  
  58.     public class Win32Methods
  59.     {
  60.  
  61.         public const int INVALID_HANDLE_VALUE = -1;
  62.  
  63.         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  64.         public struct WIN32_FIND_DATA
  65.         {
  66.             public int dwFileAttributes;
  67.             public FILETIME ftCreationTime;
  68.             public FILETIME ftLastAccessTime;
  69.             public FILETIME ftLastWriteTime;
  70.             public int nFileSizeHigh;
  71.             public int nFileSizeLow;
  72.             public int dwReserved0;
  73.             public int dwReserved1;
  74.             [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
  75.             public string cFileName;
  76.             //[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
  77.             //public string cAlternateFileName;
  78.  
  79.         };
  80.  
  81.         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  82.         public struct FILETIME
  83.         {
  84.             public uint dwLowDateTime;
  85.             public uint dwHighDateTime;
  86.         };
  87.  
  88.         //Findfirstfile
  89.         [DllImport("coredll", CharSet = CharSet.Unicode, SetLastError = true)]
  90.         public static extern int FindFirstFile(string szSearchFile, out WIN32_FIND_DATA lpFindFileData);
  91.  
  92.         //FindNextFile
  93.         [DllImport("coredll", CharSet = CharSet.Unicode, SetLastError = true)]
  94.         [return: MarshalAs(UnmanagedType.Bool)]
  95.         public static extern bool FindNextFile(int hFindFile,out WIN32_FIND_DATA lpFindFileData);
  96.         //Findclose
  97.         [DllImport("coredll", CharSet = CharSet.Unicode)]
  98.         [return: MarshalAs(UnmanagedType.Bool)]
  99.         public static extern bool FindClose(int hFindFile);
  100.     }
  101.  
  102. }
  103.  
thanks in advance
Nov 23 '07 #1
1 3515
gudiya
4
I also want to mention the same code when i make as normal c# windows application(not pocket pc) it works.Please help.It's urgent
Nov 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: jason | last post by:
Is there Python ON WinCE.net(x86) platform?
1
by: chanmy8 | last post by:
does python supported in WinCE/ProcketPC?
1
by: Monica Cummings | last post by:
Hi, how can I a bitmap in a embedded visual c++ for winCe included??? Thanks a lot Mónica
0
by: Kenric Li | last post by:
Hi, Can anyone give me any advice on what the dll : CEUDPPerfExt.dll in Windows CE 4.0 is for? The methods implemented in it include: CloseCEUDPStats CollectCEUDPStats DllRegisterServer...
1
by: Beyers | last post by:
Hi We are using active sync to connect VS.NET to a WinCE hardware platform for debuggging the application we are writing for this platform. It worked well for a month, and now all of a sudden...
1
by: Frederic_BD | last post by:
Hello! I am trying to get a list of all the process running on WinCE. I first developed my code on NT (which is working fine) and now I am porting it to WinCE 4.20. I am using embedded Visual...
2
by: parth_mca | last post by:
i want to start WinCE programming in vb.net... which version of visual studio.net supports winCE programming for PocketPC ? and where should i start from...?
2
by: bokiteam | last post by:
Hi All, I am developing a WinCE project, when I include datagrid, it says no define.. could you please advice? it works on Win32 project by the same code... Thank you very much for you...
3
by: pcm | last post by:
Hi, Has anyone ever worked on a Python-WinCE-based program that involved serial port management ? Regards, Philippe
1
by: TheSebaster | last post by:
I wrote the following lines of code under Microsoft Visual Studio 2005: I compile my WinCE c++ application importing MyInterop.tlb generated file. The MyInterop.tlh generated file do not contain my...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.