473,840 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

4 New Member
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 3569
gudiya
4 New Member
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
1538
by: jason | last post by:
Is there Python ON WinCE.net(x86) platform?
1
1925
by: chanmy8 | last post by:
does python supported in WinCE/ProcketPC?
1
2133
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
907
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 DllUnregisterServer
1
2291
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 we cannot connect to debug anymore! We have tried re-installation of our whole platform, from operating system (XP Prof) to VS.NET, but we still cannot connect to the WinCE platform via activesync.
1
2274
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 C++ 4 SP2. My problem is that the callback function is called only once and my program crashes. No exception seems to be thrown. Do you have some suggestions on what may be the problem?
2
1374
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
1624
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 help!
3
2739
by: pcm | last post by:
Hi, Has anyone ever worked on a Python-WinCE-based program that involved serial port management ? Regards, Philippe
1
2487
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 interface definition. Does anyone could help me?? (Aditional info) -When I open tlb file with visual studio and I expand MyInterop Library, I don't see any interface - I generate Interop.tlb with REGASM.EXE myinterop.dll /tlb:MyInterop.tlb...
0
10916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10598
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7836
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.