I set to copy a text file from a module to SharePoint server directory
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="MyModule">
<File IgnoreIfAlreadyExists="TRUE" Path="MyModule\newFile.txt" Url="MyModule/newFile.txt" />
</Module>
</Elements>
After that, in featureActivated, I am going to get the file by this code:
try
{
SPFile newFile = myWeb.GetFile(properties.Definition.RootDirectory + "\\MyModule\\newFile.txt");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
I got this exception : “Value does not fall within the expected range”. What is wrong with me?