473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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.com) 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/lanmanredirector/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 1616

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

Similar topics

4
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...
1
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...
3
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
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: ...
0
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...
12
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...
2
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...
1
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...
6
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.