473,387 Members | 1,486 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,387 software developers and data experts.

Copied file has System and Hidden attribute set.

I have a .Net web service that converts the MODCA files to tif or png file
format.
This web service runs on a 2003 server.

This web service first copies the MODCA file to be converted to a temporary
conversion folder.
Then it converts it to the desired file format and copies the file to the
output folder specified.
Then it deletes the converted file from the temporary conversion folder.
Then it attempts to delete the copied input file from the temporary
conversion folder
The file is not getting deleted. When I look in the explorer, I see that
the copied files get a System, Hidden and Read only attributes.

The source file does not have the System and Hidden attribute set.

Why would the copied file have System, Hidden and Read only attributes set
and how can we prevent these attributes from being set during copy?

Nov 3 '08 #1
5 3028
Hello John,

Glad to see you again and thanks for using the Microsoft Managed Newsgroup
Support Service. This is Ji Zhou [MSFT] and I will be working on this issue
with me.

I have a quick test on my side but did not reproduce your issue. When I use
the System.IO.File.Copy() method to copy a file to a temporary folder on my
side, the copied file will have the same attributes as the original one.

Actually from my testing, even if I set the copied file's attributes to
System|Hidden|ReadOnly manually, I still can delete it from my local driver
without any error. So, would you mind letting us to know the exact
exception text you received when trying to delete the copied file? In my
opinion, this issue should not be related to the file attribute.

Here are some suggestions from me depending on whether the issue always
occurs, or only happens for some time?

*If it always occurs, considering that before we view its attributes in the
explorer, our WebService has opened, manipulated, converted the copied to
new format file, I think the error we are facing resulted from not closing
the FileStream after using it. The correct version codes will roughly look
like,

private void button1_Click(object sender, EventArgs e)
{
System.IO.FileStream fs = System.IO.File.Open(@"D:\Temporary\test.txt",
System.IO.FileMode.Open);
//codes to convert the format
fs.Close(); //make sure we close the file stream.
}

*And if this issue only happens from time to time, to narrow down issues
about file cannot get deleted, I recommend to download the tool Process
Explorer from http://technet.microsoft.com/en-us/s.../bb896653.aspx
for troubleshooting. This tool can be used to find the file handle's
ownership. You can get more detailed information in the following Microsoft
KB article,
http://support.microsoft.com/kb/232830

Please let me know if the above information helps to resolve your problem.
If not, would you mind posting some of your codes about format converting
or sending a mini reproducible project to me at v-****@microsoft.com. I
will try my best to help.
Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 4 '08 #2
Hello Ji Zhou

Unfortunately this is happening on a customer’s machine in production and we
have not captured the exception text. We are suspicious that the delete
issue is that the file is marked as system.

We can not reproduce the issue on our development servers.

What I was hoping was that you could provide some insight on why/how the
attributes of the copied file would be changed from the source file in this
scenario. This code is running in a web service using the default
application pool a under Network Service account.
"""Ji Zhou [MSFT]""" wrote:
Hello John,

Glad to see you again and thanks for using the Microsoft Managed Newsgroup
Support Service. This is Ji Zhou [MSFT] and I will be working on this issue
with me.

I have a quick test on my side but did not reproduce your issue. When I use
the System.IO.File.Copy() method to copy a file to a temporary folder on my
side, the copied file will have the same attributes as the original one.

Actually from my testing, even if I set the copied file's attributes to
System|Hidden|ReadOnly manually, I still can delete it from my local driver
without any error. So, would you mind letting us to know the exact
exception text you received when trying to delete the copied file? In my
opinion, this issue should not be related to the file attribute.

Here are some suggestions from me depending on whether the issue always
occurs, or only happens for some time?

*If it always occurs, considering that before we view its attributes in the
explorer, our WebService has opened, manipulated, converted the copied to
new format file, I think the error we are facing resulted from not closing
the FileStream after using it. The correct version codes will roughly look
like,

private void button1_Click(object sender, EventArgs e)
{
System.IO.FileStream fs = System.IO.File.Open(@"D:\Temporary\test.txt",
System.IO.FileMode.Open);
//codes to convert the format
fs.Close(); //make sure we close the file stream.
}

*And if this issue only happens from time to time, to narrow down issues
about file cannot get deleted, I recommend to download the tool Process
Explorer from http://technet.microsoft.com/en-us/s.../bb896653.aspx
for troubleshooting. This tool can be used to find the file handle's
ownership. You can get more detailed information in the following Microsoft
KB article,
http://support.microsoft.com/kb/232830

Please let me know if the above information helps to resolve your problem.
If not, would you mind posting some of your codes about format converting
or sending a mini reproducible project to me at v-****@microsoft.com. I
will try my best to help.
Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 4 '08 #3
QSIDeveloper wrote:
I have a .Net web service that converts the MODCA files to tif or png
file format.
This web service runs on a 2003 server.

This web service first copies the MODCA file to be converted to a
temporary conversion folder.
Then it converts it to the desired file format and copies the file to
the output folder specified.
Then it deletes the converted file from the temporary conversion
folder. Then it attempts to delete the copied input file from the
temporary conversion folder
The file is not getting deleted. When I look in the explorer, I see
that the copied files get a System, Hidden and Read only attributes.

The source file does not have the System and Hidden attribute set.

Why would the copied file have System, Hidden and Read only
attributes set and how can we prevent these attributes from being set
during copy?
Are the new files /inheriting/ the attributes? Couldn't you explicitly set
the attributes the way you need them to be?

Andrew
Nov 4 '08 #4
Hello John,

Thanks for the information! Since the issue only happens on a particular
user's computer, we can say it should not be related to our codes, but
related to the specific environment, right?

If that is the case, my best guess is that the file's attributes may be
changed by other applications or services running on that computer, like
Google Desktop Search, Winzip, Windows Searching Index or a virus-anti
software. These applications has a commonness that may run in background to
iterate through all files on the local driver, and lock, manipulate them. I
would like suggest your customer to check this.

By the way, I am not very sure if the System attribute is the real root of
the problem. In my opinion, when a file cannot be deleted, the most two
possibility to are,

1.Security issue. If the current user does not have the permission to
delete the System attribute file, the issue can occur.

2.Lock issue. The file is manipulated by another process and not released.
That is to say the file is locked.
However, I highly recommend you two tools that may be very helpful to
troubleshooting this issue.

1.The Process Explorer which I have mentioned in my first reply already. If
the reason is the file is locked by other process. We can easily find the
file handle's ownership in the Process Explorer as described in the
Microsoft KB articles.

2.The Process Monitor which is available in this link
http://technet.microsoft.com/en-us/s.../bb896645.aspx. This tool is
also very powerful to trace all actions on all files in the machine. In
this case, we can find which application changes the file's attribute to
System|Hidden|ReadOnly. The following is an example. If I set a
file(D:\test.txt)'s attribute to ReadOnly|Hidden from explorer, I can find
the following log in ProcessMon,

9612 4:25:23.3918150 PM Explorer.EXE 3724 SetBasicInformationFile
D:\test.txt SUCCESS CreationTime: 1/1/1601 8:00:00 AM, LastAccessTime:
1/1/1601 8:00:00 AM, LastWriteTime: 1/1/1601 8:00:00 AM, ChangeTime:
1/1/1601 8:00:00 AM, FileAttributes: RHAN
Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 5 '08 #5
We discovered that a 3rd party tool we are using was writing to the input
file and that was changing the attributes.

Thanks for the help.
"""Ji Zhou [MSFT]""" wrote:
Hello John,

Thanks for the information! Since the issue only happens on a particular
user's computer, we can say it should not be related to our codes, but
related to the specific environment, right?

If that is the case, my best guess is that the file's attributes may be
changed by other applications or services running on that computer, like
Google Desktop Search, Winzip, Windows Searching Index or a virus-anti
software. These applications has a commonness that may run in background to
iterate through all files on the local driver, and lock, manipulate them. I
would like suggest your customer to check this.

By the way, I am not very sure if the System attribute is the real root of
the problem. In my opinion, when a file cannot be deleted, the most two
possibility to are,

1.Security issue. If the current user does not have the permission to
delete the System attribute file, the issue can occur.

2.Lock issue. The file is manipulated by another process and not released.
That is to say the file is locked.
However, I highly recommend you two tools that may be very helpful to
troubleshooting this issue.

1.The Process Explorer which I have mentioned in my first reply already. If
the reason is the file is locked by other process. We can easily find the
file handle's ownership in the Process Explorer as described in the
Microsoft KB articles.

2.The Process Monitor which is available in this link
http://technet.microsoft.com/en-us/s.../bb896645.aspx. This tool is
also very powerful to trace all actions on all files in the machine. In
this case, we can find which application changes the file's attribute to
System|Hidden|ReadOnly. The following is an example. If I set a
file(D:\test.txt)'s attribute to ReadOnly|Hidden from explorer, I can find
the following log in ProcessMon,

9612 4:25:23.3918150 PM Explorer.EXE 3724 SetBasicInformationFile
D:\test.txt SUCCESS CreationTime: 1/1/1601 8:00:00 AM, LastAccessTime:
1/1/1601 8:00:00 AM, LastWriteTime: 1/1/1601 8:00:00 AM, ChangeTime:
1/1/1601 8:00:00 AM, FileAttributes: RHAN
Best regards,
Ji Zhou (v-****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 7 '08 #6

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

Similar topics

1
by: wurlds_wurst_coder | last post by:
I want to create a directory structure and would like the folder attributes set to hidden. How can I do this and will my program be able to insert and delete files when this attribute is set. ...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
13
by: Alexandra | last post by:
Hi, I have a hidden system file that I need to read. I am logged in as an administrator. I can not change the file attributes using the windows explorer.
1
by: Lauchlan M | last post by:
Hi. I have an ASP.net project that works fine. I copied it to another project using the following steps: << (i) create a new VS.NET ASP.NET project.
4
by: tma | last post by:
I'm trying to retrieve values for my HTML from the Codebehind file and I'm unclear how to accomplish this. For example: <INPUT TYPE="hidden" NAME="amount" VALUE="xx"> How do I populate the...
4
by: Debbie Carter | last post by:
Would anyone know how to read the file attributes of a file on the hard drive to check if the file is encrypted or not? I have searched Visual Studio Help and MSDN and the samples I have found do...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
8
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
i have a GridView and a hidden field : <asp:TemplateField Visible=false > <ItemTemplate > <asp:HiddenField Value="<%#Eval("isActive")%>" id="hidIsActive" runat=server /> </ItemTemplate>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.