Virtual Happy Hour is canceled this month (March) due to Good Friday.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour is canceled this month (March) due to Good Friday.
I'm trying to upload a file in code to a directory in my File Manager called "Images" but I can't seem to get the directory name right. Any suggestions to what I'm doing wrong? This is what I've got so far but it doesn't seem to find or create a directory name "Images".
protected string UploadFile(Stream fileContent, string fileName)
{
UnifiedDirectory dir;
string virtualDir = "/Diverse/";
if (HostingEnvironment.VirtualPathProvider.DirectoryExists(virtualDir))
dir = VirtualPathHandler.Instance.GetDirectory(virtualDir, true) as UnifiedDirectory;
else
dir = UnifiedDirectory.CreateDirectory(virtualDir);
if (dir != null)
{
UnifiedFile uFile = dir.CreateFile(fileName);
Stream s = uFile.Open(FileMode.CreateNew);
byte[] buffer = new byte[fileContent.Length];
int numBytesToRead = (int)fileContent.Length;
fileContent.Read(buffer, 0, numBytesToRead);
s.Write(buffer, 0, buffer.Length);
s.Close();
fileContent.Close();
return uFile.VirtualPath;
}
else return "";
}