Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to Copy font file (FontFile.ttf) in this folder "C:\Windows\Fonts"

What I have tried:

VB
Dim FontFile As String = "C:\Font.ttf"
filecopy ("FontFile.ttf","c:\winsows\fonts\FontFile.ttf")
Posted
Updated 4-Feb-19 2:24am
v3
Comments
Maciej Los 4-Feb-19 8:03am    
And what is your issue?
Computechsoft 4-Feb-19 8:14am    
Font file copy in windows font folder "C:\Windows\Fonts"
Dave Kreskowiak 4-Feb-19 8:29am    
Considering, in the code you posted, the path to Windows is wrong...

Also, you never described what PROBLEM you're having, unless you mean to say that you have no idea how to copy a file in .NET.

1 solution

Please, refer this:
How to: Create a Copy of a File in a Different Directory in Visual Basic | Microsoft Docs[^]
File.Copy Method (System.IO) | Microsoft Docs[^]

Note: you have to use Try...Catch...Finally statement[^] to handle exceptions.

VB
Dim FontFile As String = "C:\Font.ttf"
Dim dstPath As String = "C:\Windows\Fonts\"
Try
    File.Copy(FontFile,Path.Combine(destPath, Path.GetFileName(FontFile)))
Catch ex As Exception
    MessageBox(ex.Message)
End Try


For further details, please see:
Path.Combine Method (System.IO) | Microsoft Docs[^]
Path.GetFileName Method (System.IO) | Microsoft Docs[^]
 
Share this answer
 
v2
Comments
Computechsoft 4-Feb-19 8:46am    
Thanks Maciej Los this help full
Richard Deeming 4-Feb-19 11:10am    
You should avoid hard-coding the path to the fonts folder, since that could change.
Dim dstPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Fonts)

Also, remember that your application will have to run with elevated permissions to be able to write to the fonts folder.
Maciej Los 4-Feb-19 12:09pm    
Good point, Richard!
Computechsoft 4-Feb-19 12:16pm    
but problem is font not copy in the Windows Font Folder
Maciej Los 4-Feb-19 12:19pm    
Please, read Richard's comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900