April 9, 2011 at 4:14 am
Hi All,
I have an SSIS package where I copy a template and write to the copied file. All has been going fine, until one day when the template was somehow set as "read only". (haven't figured out how that happened yet, but anyway). so when the package tried to copy - it gave "Access denied" error message. So, I was thinking about doing the following:
1. Find if the template is set as "read only"; and
2. if so, set it to "Not read only" and
3. then copy the template.
I have been doing some research and found a "File properties Task"; however I can't find that task in my installed BIDS. Also, there is no "Fileattributes" type to use either.
Could you pls help?
Thanks heaps in advance.
April 9, 2011 at 5:16 pm
I would try using a Script Task. The following code (from http://msdn.microsoft.com/en-us/library/system.io.file.setattributes.aspx ) will handle it:
Dim path As String = "C:\File\c.xml"
Dim attributes As System.IO.FileAttributes = System.IO.File.GetAttributes(path)
If (attributes And IO.FileAttributes.ReadOnly) = IO.FileAttributes.ReadOnly Then
attributes = attributes And (Not IO.FileAttributes.ReadOnly)
System.IO.File.SetAttributes(path, attributes)
End If
Dts.TaskResult = ScriptResults.Success
Russel Loski, MCSE Business Intelligence, Data Platform
April 11, 2011 at 6:49 pm
Thanks. I also realised that I need to use
Imports System.IO
I'm working on this now, and will let you know if I can copy in same step where I set the file to "Not Read Only"
April 11, 2011 at 6:50 pm
Thanks. I also realised that I need to use the following to access file attributes.
Imports System.IO
I'm working on this now, and will let you know if I can copy in same step where I set the file to "Not Read Only"
October 4, 2011 at 2:56 pm
here is an other example:
http://microsoft-ssis.blogspot.com/2011/03/get-file-properties-with-ssis.html
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply