TelegramApi C# GetFile - c#

I don't know how to specify the path to the directory where I need to save the file.
Please tell me how can I save the file to the desired directory received from the user and also create a separate folder for this user in the directory?


How to delete file from relative path in

My Debugging screenshot
I am trying to delete a file in web 4.7.1. I'm using FileInfo and checking if file exists using a relative path the points to the Uploads folder and image full name and extension. I have saving the image path in my database and I know if I use full path I will delete the file. How can I delete using the saved path?
I am thinking of modifying my database for each Image to store full path and relative path. I will use the full path for deleting file only. How can I delete without having to create a second database field for storing a full path?
One of the best ways to solve such problem (So that application wouldn't face any challenge of path access or read\write access on windows drive level).
Create virtual director and use that virtual directory to save relative path. Set up all access on virtual directory which is one time task.
Then you can use that virtual directory relative path in your code instead of full path.

Generate id for files based on file content

I am using a upload mechanism for users to upload files and the user is suppose to receive 3 different file extracted from the uploaded one in an group which is identified by the uploaded file name.
I am trying to map the output files to it's parent file.
How can generate something unique that can be linked to the files so that they are easily associated to its group.
I am using C# and SQl Server Filestream to store the files in database.
The limitation that i am facing is that I cannot rename the file provided by user.
Can someone help me out here?

Display pdf file from absolute path

I am using this code for creating pdf viewer in my application
it works fine when I give it a path for a file inside my application folders, ex: displaypdf1.FilePath= #"~/MyFolder/" + Hello.pdf;
but now I want to give this displaypdf1.FilePath an absolute path to read the pdf file which is not in my application folders, I tried but it didn't work!
A web page cannot access items that are outside of the website. If you want the web page to reference files located in D:\PDFs, for example, you need to create a virtual directory in your website that points to "D:\PDFs". Then the web pages can access them by ~/PDFs/Hello.pdf.
You'll also need to ensure that the website has appropriate permissions to access the directory.

How to extract name/data from database and use it as my folder name which is created dynamically in c# using server.MapPath()?

I have used AjaxFileUpload to upload multiple image files. Now i want to store the uploaded images inside rootfolder>subfolder.
The rootfolder is in the name of the user.
The rootfolder is created dynamically by taking the session of the user who has logged in
Like this:
string username = Session["username"].ToString();
I am able to create this folder and save images in it. but i want to save it in subfolder.
the subfolder is also created dynamically but this time i have to take the value(id) from the database and name the folder by that id name. (this is so that i can refer to the database)
I know how to create a new folder using Server.MapPath();
Here is the code for it in brief
using System.IO
if (Directory.Exists(Server.MapPath(uploadPath))) return;
else Directory.CreateDirectory(Server.MapPath(uploadPath));
where uploadPath is the folder's name i want to create dynamiclly.
but how do I include the subfolder too in my Server.MapPath() so as to make my path as rootfolder/subfolder ?
Small example to make the question understandable.
I am a seller. I have posted 4 ads online.
Now when i am posting my 5th ad i want to include many images.
these images should be saved in the folder
(where Seller is the username(main folder), 5 is the advertID in the database and the name of the subfolder)
How do i do this? Please help.
I am using c#
As far as I know, you can't do one statement to create folder and subfolders because you need the folder to be created first.
You have all of the code you need, you just need to repeat it. Check to see if the main folder (username) exists. If it doesn't create it, if it does, check to see if the subfolder exists. If it doesn't, create it.
Just work through that logic and you'll be set.
User Path.Combine to add your root and the user id:
var userPath = Path.Combine(uploadPath,userID)
This is the safest way to create what you need. The Directory.CreateDirectory method will create all the subfolders as needed:
var userPath = Path.Combine(uploadPath,userID)
if (Directory.Exists(Server.MapPath(userPath))) return;
else Directory.CreateDirectory(Server.MapPath(userPath));

Fetching the username who last modified or created the file

Is it possible to get the name of the user who just pasted a file into a folder?
A brief overview of what I am trying to do:
My application keeps watch on a folder for new files every 10 minutes. If it finds any new file it will upload that file via FTP to a specified location.
I would like to know who dropped this file into the folder. Please note that this could be different from the person who created the file.
The identity of the user modifying a file is not stored in the NTFS Change Journal, but you could use auditing of file access as suggested in this related post.