473,769 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Createfile/Writefile for a file on a shared directory

I have a piece of code which is moved to .NET VC7 recently from VC6 and there
has been an apparent change in behavior using CreateFile/Writefile
functionality.

I am creating a file on a shared drive using the win32 Api and using the
handle returned, i call writefile giving number of bytes to write as 1MB.

Shared directory on the machine maps to F: drive ( "shared" is the directory
name maps to " F:")
In VC6 on executing CreateFile("//mymachinename/shared/abcd.txt", ... )
My process gets the file handle which points to the absolute path of the
file i.e.
F:/abcd.txt . In FileMon ( sysinternals.co m) i get IRP_MJ_WRITE done by my
process each with 1MB size. Using the same code in .NET with the same
parameters to CreateFile, my process get the handle to the file as
/device/lanmanredirecto r/mymachinename/shared/abcd.txt while system process
gets the handle to F:/abcd.txt. On executing WriteFile, ( In FileMon) i see
that its the system process who takes the ownership of the writes and writes
are happening in chunks of 20 - 40k which is killing the performance.

A hack - If i give absolute path to Createfile("F:/abcd.txt", ..), my
process gets the correct handle and i am able to do 1 MB writes.

Query : - Are there any specific compiler settings/ registry settings which
needs to be changed to get the desired results with the original code.
Thanks
Nitin


Jul 21 '05 #1
0 1695

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8702
by: dim | last post by:
Copied directly from exaple book but not working.... All i get is an empty 0 byte file Call to GetLastError directly after the call to WriteFile returns 0 (NO_ERROR) but no data sees to be written :-( ?????????? Thx
1
16710
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and WriteFile I have written C code which works fine, just the VB translation/port
3
1866
by: red | last post by:
I have this: using System; using System.Runtime.InteropServices; using System.Text; class FileReader { const uint GENERIC_READ = 0x80000000; const uint OPEN_EXISTING = 3;
5
6326
by: Andrew Clark | last post by:
Hello, Thanks for all replies on this subject. I still cannot get CreateFile to retun a good value though. I went to PInvoke.net and saw the VB.NET declaration of this function: <DllImport("kernel32.dll", SetLastError:=True)> Private Shared Function CreateFile(ByVal lpFileName As String, ByVal dwDesiredAccess As EFileAccess, ByVal dwShareMode As EFileShare, ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As...
0
369
by: Nitin Narang | last post by:
I have a piece of code which is moved to .NET VC7 recently from VC6 and there has been an apparent change in behavior using CreateFile/Writefile functionality. I am creating a file on a shared drive using the win32 Api and using the handle returned, i call writefile giving number of bytes to write as 1MB. Shared directory on the machine maps to F: drive ( "shared" is the directory name maps to " F:") In VC6 on executing...
12
21136
by: Terry Olsen | last post by:
I'm trying to create a disk image of a floppy disk. Since I can't open the device using the system.io methods, i'm trying to use the CreateFile API to get a handle for me. But the call fails (returning a -1). Here's the code: Const GENERIC_READ = &H80000000 Const OPEN_EXISTING = 3 Const FILE_SHARE_READ = &H1 Const FILE_SHARE_WRITE = &H2 Const FILE_ATTRIBUTE_NORMAL = &H80
2
2545
by: Vadim | last post by:
Hi, I will have to send a file to a user's browser to be opened in a Save, Open manner, I am using HttpResponse.WriteFile for this, the info to be sent will have to be first accumulated in a temp file in a temp directory and sent to a user and then I would want to delete the temp file. Please let me know if the following sequence will be correct: HttpResponse.WriteFile(TempFileName) HttpResponse.End
1
4403
by: Joe B. | last post by:
I have been wading through using SetupDi... API to get a device path to use in CreateFile so that I could open a USB HID device. I can now get a device path, but when I try to open for GENERIC_READ|GENERIC_WRITE, I get an error that only tells me "Access Denied". If I use zero in dwDesiredAccess, I get a valid handle that I can use for device query access and use HidD_GetAttributes to read the Vendor ID and Product ID so on that level I...
6
5658
by: MIUSS | last post by:
Hello I got an unusual problem and I don't know how to solve it out. I need to get success with the handle variable hFile. It's not problem 'til I use wcscpy(...). I mean, when I take out those two double- slashes the source is not working and the func CreateFile returns 0xFFFFFF to that variable. It seems to me that it has some context with using wcscpy? But why?
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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
7408
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
5298
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.