hi dharmedr sir,
sir i have written a code to check my hard drive space and generate a message to my number if hard drive space consumed greater than 90%.
can u help me how to convert it according to my sms api which is
https://xyz.abc.com/sendsms_url.html?Username=xxxxxxxxxxx&Password=xxxxxxx&From=ABC&To={0}&Message={1}
THIS IS MY SMS API.
Now please help for writing my code according to this API.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.TwiML;
using Twilio.AspNet.Mvc;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetTotalFreeSpace("C:\\");
}
private void GetTotalFreeSpace(string driveName)
{
System.IO.DriveInfo dDrive = new System.IO.DriveInfo(driveName);
if (dDrive.IsReady)
{
double freeSpacePerc = (dDrive.AvailableFreeSpace / (float)dDrive.TotalSize) * 100;
if (freeSpacePerc >= 90)
{
// Code for sending message to mobile using any api..
string fromPhoneNumber = "";
string toPhoneNumber = "to_phone_number";
string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
TwilioClient.Init(accountSid, authToken);
MessageResource.Create(
body: "Your hard drive space is consumed above 90%",
from: new Twilio.Types.PhoneNumber(fromPhoneNumber),
to: new Twilio.Types.PhoneNumber(toPhoneNumber)
);
}
}
}
}
}