FileSync/FileSync/B2SDK.cs
/// <summary>
/// Deletes a specific version of a file given a filename and id
/// </summary>
/// <param name="fileName"> Name of file</param>
/// <param name="fileId"> Id of file to delete</param>
/// <returns> True if successful, false if unsuccessful</returns>
Deletes a specific version of a file given a filename and id
Deletes a specific version of a file given a filename and id
public bool b2_delete_file_version(string fileName, string fileId)
        {
            if (!checkStringParamsNotEmpty(new string[] { fileName, fileId }) || !authorized)
            {
                return false;
            }
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl + "/b2api/v1/b2_delete_file_version");
            string body =
               "{\"fileName\":\"" + fileName + "\",\n" +
               "\"fileId\":\"" + fileId + "\"}";
            var data = Encoding.UTF8.GetBytes(body);
            webRequest.Method = "POST";
            webRequest.Headers.Add("Authorization", authorizationToken);
            webRequest.ContentType = "application/json; charset=utf-8";
            webRequest.ContentLength = data.Length;
            using (var stream = webRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
                stream.Close();
            }
            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                response.Close();
                return true;
            }
            else
            {
                response.Close();
                return false;
            }
        }
public bool b2_delete_file_version ( string fileName , string fileId ) { if ( ! checkStringParamsNotEmpty ( new string [ ] { fileName , fileId } ) || ! authorized ) { return false ; } HttpWebRequest webRequest = ( HttpWebRequest ) WebRequest . Create ( apiUrl + " " ) ; string body = " \" \" \" " + fileName + " \" \n " + " \" \" \" " + fileId + " \" " ; var data = Encoding . UTF8 . GetBytes ( body ) ; webRequest . Method = " " ; webRequest . Headers . Add ( " " , authorizationToken ) ; webRequest . ContentType = " " ; webRequest . ContentLength = data . Length ; using ( var stream = webRequest . GetRequestStream ( ) ) { stream . Write ( data , 0 , data . Length ) ; stream . Close ( ) ; } HttpWebResponse response = ( HttpWebResponse ) webRequest . GetResponse ( ) ; if ( response . StatusCode == HttpStatusCode . OK ) { response . Close ( ) ; return true ; } else { response . Close ( ) ; return false ; } }
Deletes a specific version of a file given a filename and id
Deletes a specific version of a file given a filename and id
True if successful, false if unsuccessful
True if successful false if unsuccessful
fileName
string
Name of file
Name of file
fileId
string
Id of file to delete
Id of file to delete