Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RENAME command may change file security attributes
Message
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Title:
RENAME command may change file security attributes
Miscellaneous
Thread ID:
01124594
Message ID:
01124594
Views:
45
Now it is obvious.

I am writing a VFP code for cropping and scaling images in a directory on a server. These images are to be accessed from a webpage through Internet Guest Account.

An optimized image (cropped and scaled) is created from a large original image and initially saved in TEMP folder. After user's approval the large original image is replaced with an optimized image.
RENAME (originalimage) TO (interimfile)
RENAME (optimizedimage) TO (originalimage)
DELETE FILE interimfile
The .Net code inside the webpage creates new Bitmap object from the specified file.
Dim b As Bitmap = New Bitmap(originalimage)
or
Dim fs as FileStream = New FileStream(originalimage, FileMode.Open)
Dim b As Bitmap = New Bitmap(fs)
Image's dimensions can be obtained from Bitmap's Width and Height properties. I need to know them for scaling the image on the web page by setting the Width and Height values inside IMG HTML tag.

I have found that RENAME command in the code above changes file security attributes, which makes the .Net Bitmap constructor fail.

So I have switched to another code solving this issue. The code replaces the image's content without changing its security attributes:
hFile = FOPEN(originalimage, 1)
= FCHSIZE(hFile, 0)  && truncates the file
= FWRITE(hFile, FILETOSTR(optimizedimage))
= FCLOSE(hFile)
Next
Reply
Map
View

Click here to load this message in the networking platform