|
-
May 3rd, 2012, 12:49 AM
#1
Thread Starter
New Member
Copy paste error
Hi,
I'm trying to copy a picture from one location and paste it into another location however VB throws out the following error
Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
both locations are on my local computer. So not sure what is causing the problem.
Here's the code
Module CPASU_SPC
Sub Main()
Console.Title = "MOARW Programs"
Console.WriteLine("Begin Application" & vbLf)
Console.Beep()
Console.ReadLine()
Dim objFSO
Dim CPASU_Journal, vSharePoint, fsoSource, fsoDest
objFSO = CreateObject("Scripting.FileSystemObject")
CPASU_Journal = "C:\XX\XXX\Documents\Team docs\JMP Analysis\HTML"
vSharePoint = "C:\XXX\XX\Documents\Team docs\JMP Analysis\Sample"
Console.WriteLine("Begin pic upload... " & vbLf)
fsoSource = CPASU_Journal & "\gfx\Image1.png"
fsoDest = vSharePoint
Console.Write(fsoSource)
Console.Write(fsoDest)
objFSO.CopyFile(fsoSource, fsoDest)
Kill(fsoSource)
End Sub
End Module
-
May 3rd, 2012, 01:16 AM
#2
Re: Copy paste error
Why are you creating a FileSystemObject using late-binding when .NET has two different ways to copy files using only managed code? If you're using .NET then use .NET. Either use File.Copy or My.Computer.FileSystem.CopyFile.
-
May 3rd, 2012, 01:59 AM
#3
Thread Starter
New Member
Re: Copy paste error
To be honest I was looking at a sample code and tried to replicate it...Appreciate it if u can tell me when to use filesystmobject code and when to use managed code...Also the differenced...
thank u
-
May 3rd, 2012, 09:12 AM
#4
Re: Copy paste error
Always use managed code, i.e. .NET, if you can. Only use unmanaged code if there is no managed option.
-
May 3rd, 2012, 10:53 AM
#5
Thread Starter
New Member
Re: Copy paste error
Ok here's an update.
The destination is actually a sharepoint site. However it was not working with the FileStreamObject that I used earlier. At the same time this below code din't work either.
My.Computer.FileSystem.CopyFile( _
CPASU_Journal & "\gfx\Image1.png", _
"http://moss.dell.com/sites/mscontacts/CPASU/default.aspx\Image1.png", _
as it says links cannot be used in the syntax. Can anyone please tell me what function should I use for saving the file/image to a sharepoint site.
Thanks,
A
-
May 3rd, 2012, 01:52 PM
#6
Thread Starter
New Member
Re: Copy paste error
Here;s the code that I'm trying to use.
vb Code:
Module CPASU_SPC Sub Main() Console.Title = "MOARW Programs" Console.WriteLine("Begin Application" & vbLf) 'Writes text to console in a new line Console.Beep() Console.ReadLine() Dim objFSO Dim CPASU_Journal, vSharePoint, fsoSource, fsoDest objFSO = CreateObject("Scripting.FileSystemObject") CPASU_Journal = "C:\Users\**\Documents\Team docs\JMP Analysis\HTML" vSharePoint = "http://moss.****/sites/***/***/Shared Documents" fsoSource = CPASU_Journal & "\gfx\image1.png" fsoDest = vSharePoint & "/image1.png" objFSO.CopyFile(fsoSource, fsoDest) Kill(fsoSource) End Sub End Module
However I get the following exception when I run this program.
Exception from HRESULT: 0x800A0034 (CTL_E_BADFILENAMEORNUMBER)
Please help.
-
May 3rd, 2012, 02:50 PM
#7
Re: Copy paste error
"to a sharepoint site." --- ahhh.... that's the key right there...
You're getting errors because you can't copy to an HTTP address... it simply doesn't work that way... if it did, people could upload all kinds of crap to websites everywhere.
See if this is any help:
http://blog.fpweb.net/transferring-f...places-drives/
-tg
-
May 3rd, 2012, 02:53 PM
#8
Re: Copy paste error
Something I jsut remembered... SP libraries are just shared folders that are formatted by the SP server... if you can get to the library, you should be able to View As Folder, from which you can get the //server/share/folder/subfolder/uh_huh_right_here path... which you can then use with your System.Io.File.Copy
-tg
-
May 3rd, 2012, 03:54 PM
#9
Thread Starter
New Member
Re: Copy paste error
I tried using the folder location than as the server address but the System.Io.File.Copy won't allow http locations as its parameters. I tried taking out the http but it doesn't do any pasting work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|